Split GroupServ into one file per command

REGISTER/DROP/INFO/LIST/ADD/DEL/FLAGS each move to their own file; the
two shared guards (login check, can-manage) stay in lib.rs beside the
dispatcher. No behaviour change.
This commit is contained in:
Jean Chevronnet 2026-07-14 14:43:18 +00:00
parent feba6700cb
commit 1916e5fce5
No known key found for this signature in database
8 changed files with 207 additions and 179 deletions

View file

@ -0,0 +1,22 @@
use fedserv_api::{Sender, ServiceCtx, Store};
// DROP <!group>: delete a group. Founder only.
pub fn handle(me: &str, from: &Sender, name: Option<&str>, ctx: &mut ServiceCtx, db: &mut dyn Store) {
let Some(acc) = super::account(me, from, ctx) else { return };
let Some(name) = name else {
ctx.notice(me, from.uid, "Syntax: DROP <!group>");
return;
};
let Some(g) = db.group(name) else {
ctx.notice(me, from.uid, format!("\x02{name}\x02 isn't registered."));
return;
};
if !g.founder.eq_ignore_ascii_case(acc) {
ctx.notice(me, from.uid, format!("Only \x02{name}\x02's founder can drop it."));
return;
}
match db.group_drop(name) {
Ok(()) => ctx.notice(me, from.uid, format!("Group \x02{name}\x02 has been dropped.")),
Err(_) => ctx.notice(me, from.uid, "Sorry, that didn't work. Please try again in a moment."),
}
}