mirror of
https://forgejo.ellis.link/continuwuation/continuwuity/
synced 2026-04-04 21:55:54 +00:00
Compare commits
2 Commits
ginger/oob
...
nex/feat/a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38bf1ccbcc | ||
|
|
b7a8cbdb42 |
@@ -4,12 +4,14 @@
|
||||
|
||||
use crate::{PAGE_SIZE, admin_command, get_room_info};
|
||||
|
||||
#[allow(clippy::fn_params_excessive_bools)]
|
||||
#[admin_command]
|
||||
pub(super) async fn list_rooms(
|
||||
&self,
|
||||
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 +30,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 local_members: Vec<_> = self
|
||||
.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.active_local_users_in_room(&room_id)
|
||||
.collect()
|
||||
.await;
|
||||
let local_members = local_members.len();
|
||||
(room_id, total_members, local_members, 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
|
||||
|
||||
Reference in New Issue
Block a user