tuwunel_admin/room/moderation/
ban_room.rs1use ruma::OwnedRoomOrAliasId;
2use tuwunel_core::{Err, Result, debug};
3
4use super::do_ban_room;
5use crate::admin_command;
6
7#[admin_command]
8pub(super) async fn ban_room(&self, room: OwnedRoomOrAliasId) -> Result {
9 debug!("Got room alias or ID: {}", room);
10
11 let admin_room_alias = &self.services.admin.admin_alias;
12
13 if let Ok(admin_room_id) = self.services.admin.get_admin_room().await
14 && (room.to_string().eq(&admin_room_id) || room.to_string().eq(admin_room_alias))
15 {
16 return Err!("Not allowed to ban the admin room.");
17 }
18
19 let room_id = self.services.alias.maybe_resolve(&room).await?;
20
21 do_ban_room(self.services, &room_id).await;
22
23 self.write_str(
24 "Room banned, removed all our local users, and disabled incoming federation with room.",
25 )
26 .await
27}