add make user admin command (#136)
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
50c2d2b801
commit
01b2928d55
2 changed files with 23 additions and 0 deletions
|
@ -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<RoomMessageEventContent> {
|
||||
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<RoomId>, tag: String,
|
||||
) -> Result<RoomMessageEventContent> {
|
||||
|
|
|
@ -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<Roo
|
|||
user_id,
|
||||
room_id,
|
||||
} => 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,
|
||||
|
|
Loading…
Add table
Reference in a new issue