feat: Exclude empty rooms from !admin rooms list by default

Reviewed-By: Ginger <ginger@gingershaped.computer>
This commit is contained in:
timedout 2026-02-15 21:25:59 +00:00 committed by Jade Ellis
parent 4e1dac32a5
commit b7a8cbdb42
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2
2 changed files with 19 additions and 0 deletions

View file

@ -10,6 +10,7 @@ pub(super) async fn list_rooms(
page: Option<usize>,
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::<Vec<_>>()
.await;

View file

@ -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