api: type GroupServ flags (GroupFlag/GroupFlags via a shared flag_set! macro); delete the stringly apply_flags
All checks were successful
CI / check (push) Successful in 4m0s

This commit is contained in:
Jean Chevronnet 2026-07-17 18:47:08 +00:00
parent 2a12ebd6e3
commit bc4fada354
No known key found for this signature in database
4 changed files with 121 additions and 85 deletions

View file

@ -85,6 +85,12 @@ fn account<'a>(me: &str, from: &'a Sender, ctx: &mut ServiceCtx) -> Option<&'a s
// Whether `who` may manage `group` (founder, or holds the F/f flag).
fn can_manage(group: &echo_api::GroupView, who: &str) -> bool {
use echo_api::{GroupFlag, GroupFlags};
group.founder.eq_ignore_ascii_case(who)
|| group.members.iter().any(|m| m.account.eq_ignore_ascii_case(who) && (m.flags.contains('F') || m.flags.contains('f')))
|| group.members.iter().any(|m| {
m.account.eq_ignore_ascii_case(who) && {
let f = GroupFlags::parse(&m.flags);
f.has(GroupFlag::Founder) || f.has(GroupFlag::Manage)
}
})
}