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:
Jean Chevronnet 2026-07-14 14:48:12 +00:00
parent 0ba736615b
commit a29becb8b9
No known key found for this signature in database
6 changed files with 111 additions and 91 deletions

View file

@ -0,0 +1,20 @@
use fedserv_api::{Sender, ServiceCtx, Store};
// LIST [ALL]: operators list the open reports (or every report with ALL).
pub fn handle(me: &str, from: &Sender, arg: Option<&str>, ctx: &mut ServiceCtx, db: &mut dyn Store) {
if !super::require_oper(me, from, ctx) {
return;
}
let open_only = !arg.is_some_and(|a| a.eq_ignore_ascii_case("ALL"));
let reports = db.reports(open_only);
if reports.is_empty() {
ctx.notice(me, from.uid, if open_only { "No open reports." } else { "No reports." });
return;
}
for r in &reports {
let flag = if r.open { "" } else { " (closed)" };
let short: String = r.reason.chars().take(60).collect();
ctx.notice(me, from.uid, format!("\x02#{}\x02 {}\x02{}\x02: {}{}", r.id, r.reporter, r.target, short, flag));
}
ctx.notice(me, from.uid, format!("{} report(s). \x02VIEW\x02 <id> for detail.", reports.len()));
}