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.
19 lines
864 B
Rust
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()));
|
|
}
|