remove unnecessary displayname requirement on making user admin
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
55f71d3912
commit
9de780b56c
|
@ -373,20 +373,12 @@ pub(super) async fn force_leave_room(
|
|||
#[admin_command]
|
||||
pub(super) async fn make_user_admin(&self, user_id: String) -> Result<RoomMessageEventContent> {
|
||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||
let displayname = self
|
||||
.services
|
||||
.users
|
||||
.displayname(&user_id)?
|
||||
.unwrap_or_else(|| user_id.to_string());
|
||||
|
||||
assert!(
|
||||
self.services.globals.user_is_local(&user_id),
|
||||
"Parsed user_id must be a local user"
|
||||
);
|
||||
self.services
|
||||
.admin
|
||||
.make_user_admin(&user_id, displayname)
|
||||
.await?;
|
||||
self.services.admin.make_user_admin(&user_id).await?;
|
||||
|
||||
Ok(RoomMessageEventContent::notice_markdown(format!(
|
||||
"{user_id} has been granted admin privileges.",
|
||||
|
|
|
@ -347,10 +347,7 @@ pub(crate) async fn register_route(
|
|||
if !is_guest {
|
||||
if let Some(admin_room) = services.admin.get_admin_room()? {
|
||||
if services.rooms.state_cache.room_joined_count(&admin_room)? == Some(1) {
|
||||
services
|
||||
.admin
|
||||
.make_user_admin(&user_id, displayname)
|
||||
.await?;
|
||||
services.admin.make_user_admin(&user_id).await?;
|
||||
|
||||
warn!("Granting {user_id} admin privileges as the first user");
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ impl super::Service {
|
|||
/// Invite the user to the conduit admin room.
|
||||
///
|
||||
/// In conduit, this is equivalent to granting admin privileges.
|
||||
pub async fn make_user_admin(&self, user_id: &UserId, displayname: String) -> Result<()> {
|
||||
pub async fn make_user_admin(&self, user_id: &UserId) -> Result<()> {
|
||||
let Some(room_id) = self.get_admin_room()? else {
|
||||
return Ok(());
|
||||
};
|
||||
|
@ -65,7 +65,7 @@ impl super::Service {
|
|||
event_type: TimelineEventType::RoomMember,
|
||||
content: to_raw_value(&RoomMemberEventContent {
|
||||
membership: MembershipState::Join,
|
||||
displayname: Some(displayname),
|
||||
displayname: None,
|
||||
avatar_url: None,
|
||||
is_direct: None,
|
||||
third_party_invite: None,
|
||||
|
|
Loading…
Reference in New Issue