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:
parent
feba6700cb
commit
1916e5fce5
8 changed files with 207 additions and 179 deletions
20
modules/groupserv/src/list.rs
Normal file
20
modules/groupserv/src/list.rs
Normal 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()));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue