move room moderation stuff to a subcommand
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
c9364dc077
commit
e25d574208
1 changed files with 137 additions and 126 deletions
|
@ -166,6 +166,22 @@ enum RoomCommand {
|
|||
/// - List all rooms the server knows about
|
||||
List { page: Option<usize> },
|
||||
|
||||
#[command(subcommand)]
|
||||
/// - Manage moderation of remote or local rooms
|
||||
Moderation(RoomModeration),
|
||||
|
||||
#[command(subcommand)]
|
||||
/// - Manage rooms' aliases
|
||||
Alias(RoomAliasCommand),
|
||||
|
||||
#[command(subcommand)]
|
||||
/// - Manage the room directory
|
||||
Directory(RoomDirectoryCommand),
|
||||
}
|
||||
|
||||
#[cfg_attr(test, derive(Debug))]
|
||||
#[derive(Subcommand)]
|
||||
enum RoomModeration {
|
||||
/// - Bans a room ID from local users joining and evicts all our local users from the room.
|
||||
///
|
||||
/// Server admins (users in the conduwuit admin room) will not be evicted and server admins can still join the room.
|
||||
|
@ -182,14 +198,6 @@ enum RoomCommand {
|
|||
|
||||
/// - List of all rooms we have banned
|
||||
ListBannedRooms,
|
||||
|
||||
#[command(subcommand)]
|
||||
/// - Manage rooms' aliases
|
||||
Alias(RoomAliasCommand),
|
||||
|
||||
#[command(subcommand)]
|
||||
/// - Manage the room directory
|
||||
Directory(RoomDirectoryCommand),
|
||||
}
|
||||
|
||||
#[cfg_attr(test, derive(Debug))]
|
||||
|
@ -295,6 +303,7 @@ enum DebugCommand {
|
|||
event_id: Box<EventId>,
|
||||
},
|
||||
|
||||
/// - Forces device lists for all the local users to be updated
|
||||
ForceDeviceListUpdates,
|
||||
}
|
||||
|
||||
|
@ -792,7 +801,8 @@ impl Service {
|
|||
}
|
||||
},
|
||||
AdminCommand::Rooms(command) => match command {
|
||||
RoomCommand::BanRoomId { force, room_id } => {
|
||||
RoomCommand::Moderation(command) => match command {
|
||||
RoomModeration::BanRoomId { force, room_id } => {
|
||||
// basic syntax checks on room ID
|
||||
if !room_id.to_string().contains(':') {
|
||||
return Ok(RoomMessageEventContent::text_plain("Invalid room ID specified. Please note that this requires a full room ID e.g. `!awIh6gGInaS5wLQJwa:example.com`"));
|
||||
|
@ -876,11 +886,11 @@ impl Service {
|
|||
|
||||
RoomMessageEventContent::text_plain("Room banned and removed all our local users, use disable-room to stop receiving new inbound federation events as well if needed.")
|
||||
}
|
||||
RoomCommand::UnbanRoomId { room_id } => {
|
||||
RoomModeration::UnbanRoomId { room_id } => {
|
||||
services().rooms.metadata.ban_room(&room_id, false)?;
|
||||
RoomMessageEventContent::text_plain("Room unbanned, you may need to re-enable federation with the room using enable-room if this is a remote room to make it fully functional.")
|
||||
}
|
||||
RoomCommand::ListBannedRooms => {
|
||||
RoomModeration::ListBannedRooms => {
|
||||
let rooms: Result<Vec<_>, _> =
|
||||
services().rooms.metadata.list_banned_rooms().collect();
|
||||
|
||||
|
@ -918,6 +928,7 @@ impl Service {
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
RoomCommand::List { page } => {
|
||||
// TODO: i know there's a way to do this with clap, but i can't seem to find it
|
||||
let page = page.unwrap_or(1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue