infoserv: type the news kind as an enum at the store boundary
All checks were successful
CI / check (push) Successful in 3m53s

This commit is contained in:
Jean Chevronnet 2026-07-17 13:53:53 +00:00
parent ee95225eaf
commit 7a5f1502a4
No known key found for this signature in database
11 changed files with 49 additions and 31 deletions

View file

@ -1,7 +1,7 @@
use echo_api::{Priv, Sender, ServiceCtx, Store};
use echo_api::{NewsKind, Priv, Sender, ServiceCtx, Store};
// DEL/ODEL <number>: remove a bulletin by its listed position. Admin only.
pub fn handle(me: &str, from: &Sender, kind: &str, num: Option<&str>, ctx: &mut ServiceCtx, db: &mut dyn Store) {
pub fn handle(me: &str, from: &Sender, kind: NewsKind, num: Option<&str>, ctx: &mut ServiceCtx, db: &mut dyn Store) {
if !from.privs.has(Priv::Admin) {
ctx.notice(me, from.uid, "Access denied — that command is for services operators.");
return;

View file

@ -9,7 +9,7 @@
//! and any operator may OLIST. `lib.rs` holds the dispatcher; each command
//! (parameterised by bulletin kind) lives in its own file.
use echo_api::{HelpEntry, NetView, Sender, Service, ServiceCtx, Store};
use echo_api::{HelpEntry, NetView, NewsKind, Sender, Service, ServiceCtx, Store};
#[path = "post.rs"]
mod post;
@ -19,8 +19,8 @@ mod del;
mod list;
// The two bulletin kinds in the shared news store.
const PUBLIC: &str = "logon";
const OPER: &str = "oper";
const PUBLIC: NewsKind = NewsKind::Logon;
const OPER: NewsKind = NewsKind::Oper;
const BLURB: &str = "InfoServ holds the network's information bulletins: public ones show on connect, oper ones on login.";

View file

@ -1,7 +1,7 @@
use echo_api::{Sender, ServiceCtx, Store};
use echo_api::{NewsKind, 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) {
pub fn handle(me: &str, from: &Sender, kind: NewsKind, 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;

View file

@ -1,7 +1,7 @@
use echo_api::{Priv, Sender, ServiceCtx, Store};
use echo_api::{NewsKind, 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) {
pub fn handle(me: &str, from: &Sender, kind: NewsKind, 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;