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/view.rs
Normal file
17
modules/reportserv/src/view.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
use fedserv_api::{human_time, Sender, ServiceCtx, Store};
|
||||
|
||||
// VIEW <id> (aka READ): operators read a report in full.
|
||||
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(r) = id.and_then(|n| n.parse::<u64>().ok()).and_then(|n| db.report(n)) else {
|
||||
ctx.notice(me, from.uid, "No such report. Syntax: VIEW <id>");
|
||||
return;
|
||||
};
|
||||
ctx.notice(me, from.uid, format!("Report \x02#{}\x02 ({}):", r.id, if r.open { "open" } else { "closed" }));
|
||||
ctx.notice(me, from.uid, format!(" By : \x02{}\x02", r.reporter));
|
||||
ctx.notice(me, from.uid, format!(" About : \x02{}\x02", r.target));
|
||||
ctx.notice(me, from.uid, format!(" Filed : {}", human_time(r.ts)));
|
||||
ctx.notice(me, from.uid, format!(" Reason : {}", r.reason));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue