Split InfoServ into one file per command
POST/DEL/LIST each move to their own file (each still parameterised by bulletin kind, so OPOST/ODEL/OLIST route to the same handler); the kind constants stay in lib.rs beside the dispatcher. No behaviour change.
This commit is contained in:
parent
368e6ba090
commit
0ba736615b
4 changed files with 75 additions and 65 deletions
18
modules/infoserv/src/post.rs
Normal file
18
modules/infoserv/src/post.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
use fedserv_api::{Priv, Sender, ServiceCtx, Store};
|
||||
|
||||
// POST/OPOST <message>: add a bulletin (public or oper). Admin only.
|
||||
pub fn handle(me: &str, from: &Sender, kind: &str, rest: &[&str], ctx: &mut ServiceCtx, db: &mut dyn Store) {
|
||||
if !from.privs.has(Priv::Admin) {
|
||||
ctx.notice(me, from.uid, "Access denied — posting bulletins is for services operators.");
|
||||
return;
|
||||
}
|
||||
let message = rest.join(" ");
|
||||
if message.trim().is_empty() {
|
||||
ctx.notice(me, from.uid, format!("Syntax: {} <message>", if kind == super::OPER { "OPOST" } else { "POST" }));
|
||||
return;
|
||||
}
|
||||
let setter = from.account.unwrap_or(from.nick);
|
||||
db.news_add(kind, &message, setter);
|
||||
let which = if kind == super::OPER { "oper" } else { "public" };
|
||||
ctx.notice(me, from.uid, format!("Added a \x02{which}\x02 bulletin."));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue