Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Stabilize set_displayname() in module API (#14628)
Browse files Browse the repository at this point in the history
  • Loading branch information
emgrav committed Dec 6, 2022
1 parent e863a99 commit aa5ee83
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/14629.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adds a stable `set_displayname()` method to the module API for setting a user's display name.
31 changes: 31 additions & 0 deletions synapse/module_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,37 @@ async def create_room(

return room_id_and_alias["room_id"], room_id_and_alias.get("room_alias", None)

async def set_displayname(
self,
target_user: UserID,
requester_user_id: UserID,
new_displayname: str,
deactivation: bool = False,
) -> None:
"""Sets a user's display name.
Added in Synapse v1.74.0.
Args:
target_user:
The user whose display name is to be changed.
requester:
The user attempting to make this change.
new_displayname:
The new display name to give the user.
deactivation:
Whether this change was made while deactivating the user.
"""
requester = create_requester(requester_user_id)
by_admin = await self.is_user_admin(requester_user_id.to_string())
await self._hs.get_profile_handler().set_displayname(
target_user=target_user,
requester=requester,
new_displayname=new_displayname,
by_admin=by_admin,
deactivation=deactivation,
)


class PublicRoomListManager:
"""Contains methods for adding to, removing from and querying whether a room
Expand Down

0 comments on commit aa5ee83

Please sign in to comment.