The service pseudo-clients and the ircd protocol link sat flat at the repo root, mixed in with the daemon core and the SDK. Move them all under modules/ so the tree separates concerns cleanly: the daemon in src/, the SDK every module links against in api/, and the loadable modules — the pseudo-clients plus the protocol link — in modules/. Workspace members, the daemon's per-crate dependency paths, and each module's api path are updated to match; the docs follow. No code change.
26 lines
1.1 KiB
Rust
26 lines
1.1 KiB
Rust
use fedserv_api::{Sender, ServiceCtx, Store};
|
|
|
|
// A full mailbox rejects new memos, so nobody can be flooded.
|
|
const MAX_MEMOS: usize = 30;
|
|
|
|
// SEND <nick> <text>: leave a memo on a registered account's mailbox.
|
|
pub fn handle(me: &str, from: &Sender, account: &str, args: &[&str], ctx: &mut ServiceCtx, db: &mut dyn Store) {
|
|
if args.len() < 3 {
|
|
ctx.notice(me, from.uid, "Syntax: SEND <nick> <text>");
|
|
return;
|
|
}
|
|
let target = args[1];
|
|
let text = args[2..].join(" ");
|
|
let Some(dest) = db.resolve_account(target).map(str::to_string) else {
|
|
ctx.notice(me, from.uid, format!("\x02{target}\x02 isn't registered."));
|
|
return;
|
|
};
|
|
if db.memo_list(&dest).len() >= MAX_MEMOS {
|
|
ctx.notice(me, from.uid, format!("\x02{target}\x02's mailbox is full — they'll need to clear some memos first."));
|
|
return;
|
|
}
|
|
match db.memo_send(&dest, account, &text) {
|
|
Ok(()) => ctx.notice(me, from.uid, format!("Memo sent to \x02{target}\x02.")),
|
|
Err(_) => ctx.notice(me, from.uid, "Sorry, that didn't work. Please try again in a moment."),
|
|
}
|
|
}
|