Split ReportServ into one file per command
REPORT/LIST/VIEW/CLOSE/DEL each move to their own file; the shared oper guard stays in lib.rs beside the dispatcher. No behaviour change.
This commit is contained in:
parent
0ba736615b
commit
a29becb8b9
6 changed files with 111 additions and 91 deletions
17
modules/reportserv/src/close.rs
Normal file
17
modules/reportserv/src/close.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
use fedserv_api::{Sender, ServiceCtx, Store};
|
||||
|
||||
// CLOSE <id> (aka RESOLVE): mark a report resolved.
|
||||
pub fn handle(me: &str, from: &Sender, id: Option<&str>, ctx: &mut ServiceCtx, db: &mut dyn Store) {
|
||||
if !super::require_oper(me, from, ctx) {
|
||||
return;
|
||||
}
|
||||
let Some(n) = id.and_then(|n| n.parse::<u64>().ok()) else {
|
||||
ctx.notice(me, from.uid, "Syntax: CLOSE <id>");
|
||||
return;
|
||||
};
|
||||
if db.report_close(n) {
|
||||
ctx.notice(me, from.uid, format!("Report \x02#{n}\x02 closed."));
|
||||
} else {
|
||||
ctx.notice(me, from.uid, format!("Report \x02#{n}\x02 isn't open (or doesn't exist)."));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue