echo/modules/infoserv/src/list.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

19 lines
864 B
Rust

use echo_api::{Sender, ServiceCtx, Store};
// LIST/OLIST: show the bulletins of a kind. Public is open; oper is oper-only.
pub fn handle(me: &str, from: &Sender, kind: &str, oper_only: bool, ctx: &mut ServiceCtx, db: &mut dyn Store) {
if oper_only && !from.privs.any() {
ctx.notice(me, from.uid, "Access denied — oper bulletins are for services operators.");
return;
}
let items = db.news(kind);
let which = if kind == super::OPER { "oper" } else { "public" };
if items.is_empty() {
ctx.notice(me, from.uid, format!("There are no {which} bulletins."));
return;
}
for (i, item) in items.iter().enumerate() {
ctx.notice(me, from.uid, format!("{}. {} — by {}", i + 1, item.text, item.setter));
}
ctx.notice(me, from.uid, format!("End of {which} bulletins ({} shown).", items.len()));
}