Refactor admin rooms
This commit is contained in:
@@ -5,7 +5,7 @@ use tuwunel_core::{Err, Result};
|
|||||||
use crate::{PAGE_SIZE, admin_command, get_room_info};
|
use crate::{PAGE_SIZE, admin_command, get_room_info};
|
||||||
|
|
||||||
#[admin_command]
|
#[admin_command]
|
||||||
pub(super) async fn list_rooms(
|
pub(super) async fn room_list(
|
||||||
&self,
|
&self,
|
||||||
page: Option<usize>,
|
page: Option<usize>,
|
||||||
exclude_disabled: bool,
|
exclude_disabled: bool,
|
||||||
@@ -60,14 +60,14 @@ pub(super) async fn list_rooms(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[admin_command]
|
#[admin_command]
|
||||||
pub(super) async fn exists(&self, room_id: OwnedRoomId) -> Result {
|
pub(super) async fn room_exists(&self, room_id: OwnedRoomId) -> Result {
|
||||||
let result = self.services.metadata.exists(&room_id).await;
|
let result = self.services.metadata.exists(&room_id).await;
|
||||||
|
|
||||||
self.write_str(&format!("{result}")).await
|
self.write_str(&format!("{result}")).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[admin_command]
|
#[admin_command]
|
||||||
pub(super) async fn delete_room(&self, room_id: OwnedRoomId, force: bool) -> Result {
|
pub(super) async fn room_delete(&self, room_id: OwnedRoomId, force: bool) -> Result {
|
||||||
if self.services.admin.is_admin_room(&room_id).await {
|
if self.services.admin.is_admin_room(&room_id).await {
|
||||||
return Err!("Cannot delete admin room");
|
return Err!("Cannot delete admin room");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,11 @@ use self::{
|
|||||||
};
|
};
|
||||||
use crate::admin_command_dispatch;
|
use crate::admin_command_dispatch;
|
||||||
|
|
||||||
#[admin_command_dispatch]
|
#[admin_command_dispatch(handler_prefix = "room")]
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
pub(super) enum RoomCommand {
|
pub(super) enum RoomCommand {
|
||||||
/// - List all rooms the server knows about
|
/// - List all rooms the server knows about
|
||||||
#[clap(alias = "list")]
|
List {
|
||||||
ListRooms {
|
|
||||||
page: Option<usize>,
|
page: Option<usize>,
|
||||||
|
|
||||||
/// Excludes rooms that we have federation disabled with
|
/// Excludes rooms that we have federation disabled with
|
||||||
@@ -58,7 +57,7 @@ pub(super) enum RoomCommand {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/// - Delete room
|
/// - Delete room
|
||||||
DeleteRoom {
|
Delete {
|
||||||
room_id: OwnedRoomId,
|
room_id: OwnedRoomId,
|
||||||
|
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
|
|||||||
Reference in New Issue
Block a user