echo/modules/infoserv/src/post.rs
Jean 993f5b2eea
Rename the project to Echo (was fedserv)
Rebrand the daemon and workspace: the binary is now `echo`, every crate
is `echo-*` (`echo-api` and the module crates), Rust imports use
`echo_*`, the gRPC proto is `proto/echo.proto` with package `echo.v1`,
and the log filter, gossip peer-name default, and on-disk store default
(`echo.db.jsonl`) follow. Docs updated throughout. No behaviour change;
crate directories and the config schema are untouched.
2026-07-14 15:24:41 +00:00

18 lines
840 B
Rust

use echo_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."));
}