Merge branch 'remove-alias-command' into 'next'

feat(admin): remove alias command

See merge request famedly/conduit!685
This commit is contained in:
Matthias Ahouansou 2024-05-29 17:05:45 +00:00
commit be1b8b68a7

View file

@ -77,6 +77,12 @@ enum AdminCommand {
/// List all rooms we are currently handling an incoming pdu from /// List all rooms we are currently handling an incoming pdu from
IncomingFederation, IncomingFederation,
/// Removes an alias from the server
RemoveAlias {
/// The alias to be removed
alias: Box<RoomAliasId>,
},
/// Deactivate a user /// Deactivate a user
/// ///
/// User will not be removed from all rooms by default. /// 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) Ok(reply_message_content)