From 3f9aa8c6eb87c9ddce75cfaad9d4d6d5a5a256e0 Mon Sep 17 00:00:00 2001 From: reverse Date: Mon, 17 Aug 2026 01:50:11 +0000 Subject: [PATCH] channel: cull an empty channel when a mode change (-P/-r) removes its last reason to persist --- src/coremods/core_mode.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/coremods/core_mode.rs b/src/coremods/core_mode.rs index 5c85c6d..4b30e9f 100644 --- a/src/coremods/core_mode.rs +++ b/src/coremods/core_mode.rs @@ -176,6 +176,13 @@ pub fn apply_mode(s: &mut Server, uid: Uid, params: &[String]) -> CmdResult { let src_uuid = s.users[&uid].uuid.clone(); 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 }