add --no_details
to list banned rooms command
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
c16e5b50eb
commit
156199a218
1 changed files with 13 additions and 4 deletions
|
@ -60,7 +60,12 @@ pub(crate) enum RoomModerationCommand {
|
||||||
},
|
},
|
||||||
|
|
||||||
/// - List of all rooms we have banned
|
/// - List of all rooms we have banned
|
||||||
ListBannedRooms,
|
ListBannedRooms {
|
||||||
|
#[arg(long)]
|
||||||
|
/// Whether to only output room IDs without supplementary room
|
||||||
|
/// information
|
||||||
|
no_details: bool,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[admin_command]
|
#[admin_command]
|
||||||
|
@ -563,7 +568,7 @@ async fn unban_room(&self, enable_federation: bool, room: Box<RoomOrAliasId>) ->
|
||||||
}
|
}
|
||||||
|
|
||||||
#[admin_command]
|
#[admin_command]
|
||||||
async fn list_banned_rooms(&self) -> Result<RoomMessageEventContent> {
|
async fn list_banned_rooms(&self, no_details: bool) -> Result<RoomMessageEventContent> {
|
||||||
let rooms = self
|
let rooms = self
|
||||||
.services
|
.services
|
||||||
.rooms
|
.rooms
|
||||||
|
@ -589,7 +594,11 @@ async fn list_banned_rooms(&self) -> Result<RoomMessageEventContent> {
|
||||||
rooms.len(),
|
rooms.len(),
|
||||||
rooms
|
rooms
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(id, members, name)| format!("{id}\tMembers: {members}\tName: {name}"))
|
.map(|(id, members, name)| if no_details {
|
||||||
|
format!("{id}")
|
||||||
|
} else {
|
||||||
|
format!("{id}\tMembers: {members}\tName: {name}")
|
||||||
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\n")
|
.join("\n")
|
||||||
);
|
);
|
||||||
|
@ -597,7 +606,7 @@ async fn list_banned_rooms(&self) -> Result<RoomMessageEventContent> {
|
||||||
Ok(RoomMessageEventContent::notice_markdown(output_plain))
|
Ok(RoomMessageEventContent::notice_markdown(output_plain))
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to list banned rooms: {}", e);
|
error!("Failed to list banned rooms: {e}");
|
||||||
Ok(RoomMessageEventContent::text_plain(format!("Unable to list banned rooms: {e}")))
|
Ok(RoomMessageEventContent::text_plain(format!("Unable to list banned rooms: {e}")))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue