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,20 @@
use fedserv_api::{Sender, ServiceCtx, Store};
// LIST: operators see every group; others see the ones they belong to.
pub fn handle(me: &str, from: &Sender, ctx: &mut ServiceCtx, db: &mut dyn Store) {
let names = if from.privs.any() {
db.groups()
} else if let Some(acc) = from.account {
db.groups_of(acc)
} else {
Vec::new()
};
if names.is_empty() {
ctx.notice(me, from.uid, "No groups to show.");
return;
}
for n in &names {
ctx.notice(me, from.uid, format!(" \x02{n}\x02"));
}
ctx.notice(me, from.uid, format!("End of list ({} group(s)).", names.len()));
}