MemoServ: add SET NOTIFY and SET LIMIT
All checks were successful
CI / check (push) Successful in 3m35s
All checks were successful
CI / check (push) Successful in 3m35s
SET NOTIFY {ON|OFF} controls whether you're told about new memos on login;
SET LIMIT <n>|NONE sets your mailbox cap (honoured on SEND, NONE = the
network default). New memo_notify/memo_limit account fields + one
MemoPrefsSet event.
This commit is contained in:
parent
125b8c7701
commit
2c282d036f
14 changed files with 152 additions and 8 deletions
|
|
@ -411,7 +411,7 @@
|
|||
// An earlier claim from another node wins and takes the name over.
|
||||
let winner = db::Account {
|
||||
name: "alice".into(), email: None,
|
||||
ts: 0, home: "peer".into(), scram256: None, scram512: None, certfps: vec![], verified: true, ajoin: vec![], suspension: None, memos: vec![], memo_ignore: vec![], greet: String::new(), vhost: None, vhost_request: None, last_seen: 0, noexpire: false, expiry_warned: false, oper_note: None,
|
||||
ts: 0, home: "peer".into(), scram256: None, scram512: None, certfps: vec![], verified: true, ajoin: vec![], suspension: None, memos: vec![], memo_ignore: vec![], memo_notify: true, memo_limit: None, greet: String::new(), vhost: None, vhost_request: None, last_seen: 0, noexpire: false, expiry_warned: false, oper_note: None,
|
||||
};
|
||||
let entry = LogEntry::for_test("peer", 0, 1, db::Event::AccountRegistered(Box::new(winner)));
|
||||
e.gossip_ingest(entry).unwrap();
|
||||
|
|
@ -875,6 +875,44 @@
|
|||
assert_eq!(e.db.unread_memos("alice"), 1, "delivered once no longer ignored");
|
||||
}
|
||||
|
||||
// MemoServ SET NOTIFY/LIMIT change the account's memo preferences, and LIMIT
|
||||
// caps the mailbox on SEND.
|
||||
#[test]
|
||||
fn memoserv_set_notify_and_limit() {
|
||||
use echo_memoserv::MemoServ;
|
||||
use echo_nickserv::NickServ;
|
||||
let path = std::env::temp_dir().join("echo-msset.jsonl");
|
||||
let _ = std::fs::remove_file(&path);
|
||||
let mut db = Db::open(&path, "42S");
|
||||
db.scram_iterations = 4096;
|
||||
db.register("alice", "pw", None).unwrap();
|
||||
db.register("bob", "pw", None).unwrap();
|
||||
let mut e = Engine::new(
|
||||
vec![
|
||||
Box::new(NickServ { uid: "42SAAAAAA".into(), guest_nick: "Guest".into(), guest_seq: 0 }),
|
||||
Box::new(MemoServ { uid: "42SAAAAAE".into() }),
|
||||
],
|
||||
db,
|
||||
);
|
||||
let ms = |e: &mut Engine, uid: &str, t: &str| e.handle(NetEvent::Privmsg { from: uid.into(), to: "42SAAAAAE".into(), text: t.into() });
|
||||
let notice = |out: &[NetAction], n: &str| out.iter().any(|a| matches!(a, NetAction::Notice { text, .. } if text.contains(n)));
|
||||
e.handle(NetEvent::UserConnect { uid: "000AAAAAB".into(), nick: "alice".into(), host: "h".into(), ip: "0.0.0.0".into() });
|
||||
e.handle(NetEvent::Privmsg { from: "000AAAAAB".into(), to: "42SAAAAAA".into(), text: "IDENTIFY pw".into() });
|
||||
e.handle(NetEvent::UserConnect { uid: "000AAAAAC".into(), nick: "bob".into(), host: "h".into(), ip: "0.0.0.0".into() });
|
||||
e.handle(NetEvent::Privmsg { from: "000AAAAAC".into(), to: "42SAAAAAA".into(), text: "IDENTIFY pw".into() });
|
||||
|
||||
assert!(notice(&ms(&mut e, "000AAAAAB", "SET NOTIFY OFF"), "off"), "notify off");
|
||||
assert!(!e.db.memo_notify_on("alice"), "notify pref stored");
|
||||
assert!(notice(&ms(&mut e, "000AAAAAB", "SET LIMIT 2"), "2"), "limit set");
|
||||
assert_eq!(e.db.memo_limit_of("alice"), Some(2), "limit stored");
|
||||
|
||||
// bob fills alice's 2-memo mailbox; the third is rejected.
|
||||
ms(&mut e, "000AAAAAC", "SEND alice one");
|
||||
ms(&mut e, "000AAAAAC", "SEND alice two");
|
||||
assert!(notice(&ms(&mut e, "000AAAAAC", "SEND alice three"), "mailbox is full"), "limit enforced on SEND");
|
||||
assert_eq!(e.db.unread_memos("alice"), 2, "capped at the limit");
|
||||
}
|
||||
|
||||
// ChanServ AKICK CLEAR empties the auto-kick list.
|
||||
#[test]
|
||||
fn chanserv_akick_clear() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue