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
20
modules/reportserv/src/list.rs
Normal file
20
modules/reportserv/src/list.rs
Normal 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()));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue