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

Commit aa5ee83

Browse files
committed
Stabilize set_displayname() in module API (#14628)
1 parent e863a99 commit aa5ee83

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

changelog.d/14629.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adds a stable `set_displayname()` method to the module API for setting a user's display name.

synapse/module_api/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,37 @@ async def create_room(
15471547

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

1550+
async def set_displayname(
1551+
self,
1552+
target_user: UserID,
1553+
requester_user_id: UserID,
1554+
new_displayname: str,
1555+
deactivation: bool = False,
1556+
) -> None:
1557+
"""Sets a user's display name.
1558+
1559+
Added in Synapse v1.74.0.
1560+
1561+
Args:
1562+
target_user:
1563+
The user whose display name is to be changed.
1564+
requester:
1565+
The user attempting to make this change.
1566+
new_displayname:
1567+
The new display name to give the user.
1568+
deactivation:
1569+
Whether this change was made while deactivating the user.
1570+
"""
1571+
requester = create_requester(requester_user_id)
1572+
by_admin = await self.is_user_admin(requester_user_id.to_string())
1573+
await self._hs.get_profile_handler().set_displayname(
1574+
target_user=target_user,
1575+
requester=requester,
1576+
new_displayname=new_displayname,
1577+
by_admin=by_admin,
1578+
deactivation=deactivation,
1579+
)
1580+
15501581

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

0 commit comments

Comments
 (0)