UPDATE re-applies your auto-joins and vhost and re-checks for waiting memos without re-identifying. LIST (auspex-gated) shows registered accounts matching a glob, capped at 100. Adds an accounts_matching store method.
This commit is contained in:
parent
959d085e7a
commit
21efbd32c1
6 changed files with 91 additions and 0 deletions
23
modules/nickserv/src/list.rs
Normal file
23
modules/nickserv/src/list.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use echo_api::{human_time, Priv, Sender, ServiceCtx, Store};
|
||||
|
||||
// A cap so a broad glob can't flood the requesting oper.
|
||||
const MAX_SHOWN: usize = 100;
|
||||
|
||||
// LIST <pattern>: list registered accounts matching a glob. Oper-only.
|
||||
pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db: &dyn Store) {
|
||||
if !from.privs.has(Priv::Auspex) {
|
||||
ctx.notice(me, from.uid, "Access denied — LIST needs the \x02auspex\x02 privilege.");
|
||||
return;
|
||||
}
|
||||
let pattern = args.get(1).copied().unwrap_or("*");
|
||||
let mut matches = db.accounts_matching(pattern);
|
||||
matches.sort_by_key(|a| a.name.to_ascii_lowercase());
|
||||
|
||||
ctx.notice(me, from.uid, format!("Accounts matching \x02{pattern}\x02:"));
|
||||
for a in matches.iter().take(MAX_SHOWN) {
|
||||
let flag = if a.verified { "" } else { " (unconfirmed)" };
|
||||
ctx.notice(me, from.uid, format!(" \x02{}\x02 registered {}{}", a.name, human_time(a.ts), flag));
|
||||
}
|
||||
let more = if matches.len() > MAX_SHOWN { format!(", showing the first {MAX_SHOWN}") } else { String::new() };
|
||||
ctx.notice(me, from.uid, format!("End of list — {} match(es){more}.", matches.len()));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue