From 6c2eb4c78657e5c4ef68fbcdb29648cb7ae785fe Mon Sep 17 00:00:00 2001 From: Matthias Ahouansou Date: Wed, 29 May 2024 17:38:13 +0100 Subject: [PATCH] feat(admin): remove alias command --- src/service/admin/mod.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/service/admin/mod.rs b/src/service/admin/mod.rs index 0abce70d..a6caaa26 100644 --- a/src/service/admin/mod.rs +++ b/src/service/admin/mod.rs @@ -77,6 +77,12 @@ enum AdminCommand { /// List all rooms we are currently handling an incoming pdu from IncomingFederation, + /// Removes an alias from the server + RemoveAlias { + /// The alias to be removed + alias: Box, + }, + /// Deactivate a user /// /// User will not be removed from all rooms by default. @@ -907,6 +913,23 @@ impl Service { ) } } + AdminCommand::RemoveAlias { alias } => { + if alias.server_name() != services().globals.server_name() { + RoomMessageEventContent::text_plain( + "Cannot remove alias which is not from this server", + ) + } else if services() + .rooms + .alias + .resolve_local_alias(&alias)? + .is_none() + { + RoomMessageEventContent::text_plain("No such alias exists") + } else { + services().rooms.alias.remove_alias(&alias)?; + RoomMessageEventContent::text_plain("Alias removed sucessfully") + } + } }; Ok(reply_message_content)