feat(admin): remove alias command

This commit is contained in:
Matthias Ahouansou 2024-05-29 17:38:13 +01:00
parent 3df791e030
commit 6c2eb4c786
No known key found for this signature in database

View file

@ -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<RoomAliasId>,
},
/// 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)