feat: Exclude empty rooms from !admin rooms list by default
Reviewed-By: Ginger <ginger@gingershaped.computer>
This commit is contained in:
parent
4e1dac32a5
commit
b7a8cbdb42
2 changed files with 19 additions and 0 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue