chanserv: give SOP/AOP/HOP/VOP four distinct access tiers matching Anope, classified by capability
All checks were successful
CI / check (push) Successful in 3m55s

This commit is contained in:
Jean Chevronnet 2026-07-17 14:54:36 +00:00
parent f5c976eb56
commit c8106035df
No known key found for this signature in database
6 changed files with 119 additions and 41 deletions

View file

@ -1,4 +1,4 @@
use echo_api::{level_caps, Sender, ServiceCtx, Store};
use echo_api::{access_role, Sender, ServiceCtx, Store};
// ALIST: list the channels the sender's account founds or has access on.
pub fn handle(me: &str, from: &Sender, ctx: &mut ServiceCtx, db: &dyn Store) {
@ -11,20 +11,9 @@ pub fn handle(me: &str, from: &Sender, ctx: &mut ServiceCtx, db: &dyn Store) {
if c.founder.eq_ignore_ascii_case(account) {
rows.push((c.name.clone(), "founder"));
} else if let Some(a) = c.access.iter().find(|a| a.account.eq_ignore_ascii_case(account)) {
// Resolve the entry's capabilities rather than string-matching the
// level, so a role set via granular FLAGS (e.g. "v") reads correctly
// and isn't mislabelled "op".
let caps = level_caps(&a.level);
let role = if caps.op {
"op"
} else if caps.auto == Some("+v") {
"voice"
} else if caps.auto == Some("+h") {
"halfop"
} else {
"access"
};
rows.push((c.name.clone(), role));
// Classify by resolved capability, not the raw level string, so a role
// set via granular FLAGS reads under the same tier XOP would show.
rows.push((c.name.clone(), access_role(&a.level).label()));
}
}
if rows.is_empty() {