akick: accept a matching extban only the ircd knows (ircd-enforced +b), reject acting extbans with a clear reason

This commit is contained in:
Jean Chevronnet 2026-07-17 22:01:32 +00:00
parent c990eb1e1e
commit 77d09c4bdc
No known key found for this signature in database
5 changed files with 75 additions and 21 deletions

View file

@ -187,6 +187,17 @@ impl Db {
self.live_extbans.as_ref().is_none_or(|set| set.iter().any(|e| e.name.eq_ignore_ascii_case(name)))
}
/// Resolve an extban token (name, case-insensitive; or single letter, case-
/// sensitive) against the ircd's live set. For extbans echo's static table lacks.
pub fn extban_lookup(&self, token: &str) -> Option<echo_api::ExtbanCap> {
let live = self.live_extbans.as_ref()?;
let mut chars = token.chars();
match (chars.next(), chars.next()) {
(Some(c), None) => live.iter().find(|e| e.letter == Some(c)).cloned(),
_ => live.iter().find(|e| e.name.eq_ignore_ascii_case(token)).cloned(),
}
}
/// Display name used in email templates.
pub fn email_brand(&self) -> &str {
&self.email_brand

View file

@ -60,6 +60,9 @@ impl Store for Db {
fn extban_offered(&self, name: &str) -> bool {
Db::extban_offered(self, name)
}
fn extban_lookup(&self, token: &str) -> Option<echo_api::ExtbanCap> {
Db::extban_lookup(self, token)
}
fn email_enabled(&self) -> bool {
Db::email_enabled(self)
}