From b7a8cbdb4230d88f1ccefee9a22993a4239e8fce Mon Sep 17 00:00:00 2001 From: timedout Date: Sun, 15 Feb 2026 21:25:59 +0000 Subject: [PATCH] feat: Exclude empty rooms from `!admin rooms list` by default Reviewed-By: Ginger --- src/admin/room/commands.rs | 15 +++++++++++++++ src/admin/room/mod.rs | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/src/admin/room/commands.rs b/src/admin/room/commands.rs index 81f36f15..67dd00bb 100644 --- a/src/admin/room/commands.rs +++ b/src/admin/room/commands.rs @@ -10,6 +10,7 @@ pub(super) async fn list_rooms( page: Option, exclude_disabled: bool, exclude_banned: bool, + include_empty: bool, no_details: bool, ) -> Result { // TODO: i know there's a way to do this with clap, but i can't seem to find it @@ -28,6 +29,20 @@ pub(super) async fn list_rooms( .then_some(room_id) }) .then(|room_id| get_room_info(self.services, room_id)) + .then(|(room_id, total_members, name)| async move { + let room_id2 = room_id.clone(); // this is so dumb + let local_members: Vec<_> = self + .services + .rooms + .state_cache + .active_local_users_in_room(&room_id2) + .collect() + .await; + (room_id, total_members, local_members.len(), name) + }) + .filter_map(|(room_id, total_members, local_members, name)| async move { + (include_empty || local_members > 0).then_some((room_id, total_members, name)) + }) .collect::>() .await; diff --git a/src/admin/room/mod.rs b/src/admin/room/mod.rs index f6a668fd..baa54d4b 100644 --- a/src/admin/room/mod.rs +++ b/src/admin/room/mod.rs @@ -30,6 +30,10 @@ pub enum RoomCommand { #[arg(long)] exclude_banned: bool, + /// Includes disconnected/empty rooms (rooms with zero members) + #[arg(long)] + include_empty: bool, + #[arg(long)] /// Whether to only output room IDs without supplementary room /// information