MemoServ: add IGNORE
All checks were successful
CI / check (push) Successful in 3m34s

IGNORE ADD/DEL/LIST manages a per-account memo-ignore list; a memo from
an ignored account is silently dropped, and the sender is still told it
was sent so the ignore isn't revealed. New memo_ignore account field +
events, and a check in SEND.
This commit is contained in:
Jean Chevronnet 2026-07-16 00:10:34 +00:00
parent ccbbb91fda
commit b5e08c33cf
No known key found for this signature in database
13 changed files with 167 additions and 5 deletions

View file

@ -29,6 +29,8 @@ pub enum Event {
MemoSent { account: String, from: String, text: String, ts: u64 },
MemoRead { account: String, index: usize },
MemoDeleted { account: String, index: usize },
MemoIgnoreAdd { account: String, target: String },
MemoIgnoreDel { account: String, target: String },
NickGrouped { nick: String, account: String },
NickUngrouped { nick: String },
ChannelRegistered { name: String, founder: String, ts: u64 },
@ -156,6 +158,8 @@ impl Event {
| Event::MemoSent { .. }
| Event::MemoRead { .. }
| Event::MemoDeleted { .. }
| Event::MemoIgnoreAdd { .. }
| Event::MemoIgnoreDel { .. }
| Event::NickGrouped { .. }
| Event::NickUngrouped { .. }
| Event::AccountSeen { .. }
@ -338,6 +342,18 @@ pub(crate) fn apply(accounts: &mut HashMap<String, Account>, channels: &mut Hash
}
}
}
Event::MemoIgnoreAdd { account, target } => {
if let Some(a) = accounts.get_mut(&key(&account)) {
if !a.memo_ignore.iter().any(|t| t.eq_ignore_ascii_case(&target)) {
a.memo_ignore.push(target);
}
}
}
Event::MemoIgnoreDel { account, target } => {
if let Some(a) = accounts.get_mut(&key(&account)) {
a.memo_ignore.retain(|t| !t.eq_ignore_ascii_case(&target));
}
}
Event::NickGrouped { nick, account } => {
grouped.insert(key(&nick), account);
}