diff --git a/src/admin/user/commands.rs b/src/admin/user/commands.rs index 218dadb9..9e4b348b 100644 --- a/src/admin/user/commands.rs +++ b/src/admin/user/commands.rs @@ -348,6 +348,21 @@ pub(super) async fn force_join_room( ))) } +pub(super) async fn make_user_admin(_body: Vec<&str>, user_id: String) -> Result { + let user_id = parse_local_user_id(&user_id)?; + let displayname = services() + .users + .displayname(&user_id)? + .unwrap_or_else(|| user_id.to_string()); + + assert!(service::user_is_local(&user_id), "Parsed user_id must be a local user"); + service::admin::make_user_admin(&user_id, displayname).await?; + + Ok(RoomMessageEventContent::notice_markdown(format!( + "{user_id} has been granted admin privileges.", + ))) +} + pub(super) async fn put_room_tag( _body: Vec<&str>, user_id: String, room_id: Box, tag: String, ) -> Result { diff --git a/src/admin/user/mod.rs b/src/admin/user/mod.rs index e7d3d251..cdb5fa5e 100644 --- a/src/admin/user/mod.rs +++ b/src/admin/user/mod.rs @@ -71,6 +71,11 @@ pub(super) enum UserCommand { room_id: OwnedRoomOrAliasId, }, + /// - Grant server-admin privileges to a user. + MakeUserAdmin { + user_id: String, + }, + /// - Puts a room tag for the specified user and room ID. /// /// This is primarily useful if you'd like to set your admin room @@ -123,6 +128,9 @@ pub(super) async fn process(command: UserCommand, body: Vec<&str>) -> Result force_join_room(body, user_id, room_id).await?, + UserCommand::MakeUserAdmin { + user_id, + } => make_user_admin(body, user_id).await?, UserCommand::PutRoomTag { user_id, room_id,