channel: cull an empty channel when a mode change (-P/-r) removes its last reason to persist

This commit is contained in:
Jean Chevronnet 2026-08-17 01:50:11 +00:00
parent b451ccbfd8
commit 3f9aa8c6eb

View file

@ -176,6 +176,13 @@ pub fn apply_mode(s: &mut Server, uid: Uid, params: &[String]) -> CmdResult {
let src_uuid = s.users[&uid].uuid.clone(); let src_uuid = s.users[&uid].uuid.clone();
s.propagate_chan_mode(&src_uuid, target, &applied, &echoed); s.propagate_chan_mode(&src_uuid, target, &applied, &echoed);
} }
// A mode change may have removed the channel's last reason to exist while it has
// no members (e.g. -P / -r on an empty channel): destroy it now, as an empty
// channel is normally culled the moment its final member leaves.
let cull = s.channels.get(&key).is_some_and(|c| !c.keep_alive());
if cull {
s.channels.remove(&key);
}
CmdResult::Ok CmdResult::Ok
} }