MemoServ: add RSEND read receipts
Some checks failed
CI / check (push) Has been cancelled

This commit is contained in:
Jean Chevronnet 2026-07-16 00:43:01 +00:00
parent 2850620be1
commit d819b2c75f
No known key found for this signature in database
11 changed files with 80 additions and 22 deletions

View file

@ -19,6 +19,7 @@ pub fn handle(me: &str, from: &Sender, account: &str, args: &[&str], ctx: &mut S
for i in targets {
if let Some(m) = db.memo_read(account, i) {
show(me, from, i, &m, ctx);
send_receipt(account, &m, db);
}
}
}
@ -28,7 +29,10 @@ pub fn handle(me: &str, from: &Sender, account: &str, args: &[&str], ctx: &mut S
return;
};
match db.memo_read(account, n - 1) {
Some(m) => show(me, from, n - 1, &m, ctx),
Some(m) => {
show(me, from, n - 1, &m, ctx);
send_receipt(account, &m, db);
}
None => ctx.notice(me, from.uid, format!("You have no memo #\x02{n}\x02.")),
}
}
@ -40,3 +44,12 @@ fn show(me: &str, from: &Sender, index: usize, m: &MemoView, ctx: &mut ServiceCt
ctx.notice(me, from.uid, format!("Memo #\x02{}\x02 from \x02{}\x02 ({}):", index + 1, m.from, human_time(m.ts)));
ctx.notice(me, from.uid, format!(" {}", m.text));
}
// If this was an unread RSEND memo, memo the sender that it's now been read.
// `m.read` is the pre-read state, so we only fire once, on first read.
fn send_receipt(reader: &str, m: &MemoView, db: &mut dyn Store) {
if m.receipt && !m.read {
let text = format!("{reader} has read the memo you sent them of {}.", human_time(m.ts));
let _ = db.memo_send(&m.from, "MemoServ", &text, false);
}
}