mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat: Exclude empty rooms from !admin rooms list by default
Reviewed-By: Ginger <ginger@gingershaped.computer>
This commit is contained in:
@@ -10,6 +10,7 @@ pub(super) async fn list_rooms(
|
|||||||
page: Option<usize>,
|
page: Option<usize>,
|
||||||
exclude_disabled: bool,
|
exclude_disabled: bool,
|
||||||
exclude_banned: bool,
|
exclude_banned: bool,
|
||||||
|
include_empty: bool,
|
||||||
no_details: bool,
|
no_details: bool,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
// TODO: i know there's a way to do this with clap, but i can't seem to find it
|
// 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_some(room_id)
|
||||||
})
|
})
|
||||||
.then(|room_id| get_room_info(self.services, 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<_>>()
|
.collect::<Vec<_>>()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ pub enum RoomCommand {
|
|||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
exclude_banned: bool,
|
exclude_banned: bool,
|
||||||
|
|
||||||
|
/// Includes disconnected/empty rooms (rooms with zero members)
|
||||||
|
#[arg(long)]
|
||||||
|
include_empty: bool,
|
||||||
|
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
/// Whether to only output room IDs without supplementary room
|
/// Whether to only output room IDs without supplementary room
|
||||||
/// information
|
/// information
|
||||||
|
|||||||
Reference in New Issue
Block a user