operserv: type the X-line kind as an enum at the command/store boundary, wire token in storage

This commit is contained in:
Jean Chevronnet 2026-07-17 13:47:10 +00:00
parent 2c8ba4460d
commit ef34c04c8d
No known key found for this signature in database
9 changed files with 96 additions and 45 deletions

View file

@ -1,13 +1,13 @@
use echo_api::{Sender, ServiceCtx, Store};
use echo_api::{Sender, ServiceCtx, Store, XlineKind};
// STATS: an at-a-glance summary of the enforcement state OperServ holds — how
// many network bans of each kind and how many services ignores are live.
// Read-only, so any operator may run it (the module is already oper-gated).
pub fn handle(me: &str, from: &Sender, db: &mut dyn Store, ctx: &mut ServiceCtx) {
let akills = db.akills();
let glines = akills.iter().filter(|a| a.kind == "G").count();
let qlines = akills.iter().filter(|a| a.kind == "Q").count();
let rlines = akills.iter().filter(|a| a.kind == "R").count();
let glines = akills.iter().filter(|a| a.kind == XlineKind::Gline).count();
let qlines = akills.iter().filter(|a| a.kind == XlineKind::Qline).count();
let rlines = akills.iter().filter(|a| a.kind == XlineKind::Rline).count();
let ignores = db.ignores().len();
ctx.notice(me, from.uid, format!("Live network bans: \x02{glines}\x02 AKILL, \x02{qlines}\x02 SQLINE, \x02{rlines}\x02 SNLINE. Services ignores: \x02{ignores}\x02."));
}