Split HelpServ into one file per command
REQUEST/CANCEL/LIST/VIEW/TAKE/NEXT/CLOSE each move to their own file; the oper guard and the shared claim helper stay in lib.rs beside the dispatcher. No behaviour change.
This commit is contained in:
parent
1916e5fce5
commit
368e6ba090
8 changed files with 144 additions and 115 deletions
14
modules/helpserv/src/cancel.rs
Normal file
14
modules/helpserv/src/cancel.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
use fedserv_api::{Sender, ServiceCtx, Store};
|
||||
|
||||
// CANCEL: withdraw your own newest open ticket.
|
||||
pub fn handle(me: &str, from: &Sender, ctx: &mut ServiceCtx, db: &mut dyn Store) {
|
||||
let who = from.account.unwrap_or(from.nick);
|
||||
let mine = db.help_tickets(true).into_iter().find(|t| t.requester.eq_ignore_ascii_case(who));
|
||||
match mine {
|
||||
Some(t) => {
|
||||
db.help_close(t.id);
|
||||
ctx.notice(me, from.uid, format!("Your request \x02#{}\x02 has been cancelled.", t.id));
|
||||
}
|
||||
None => ctx.notice(me, from.uid, "You have no open request to cancel."),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue