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

Commit

Permalink
Add - remote join capability to the module API "update_room_membershi…
Browse files Browse the repository at this point in the history
…p" method,

in a backwards compatible manner.
  • Loading branch information
buffless-matt committed Aug 3, 2022
1 parent 1c910e2 commit 6e2b45d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions synapse/module_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
JsonMapping,
Requester,
RoomAlias,
RoomID,
StateMap,
UserID,
UserInfo,
Expand Down Expand Up @@ -929,6 +930,7 @@ async def update_room_membership(
room_id: str,
new_membership: str,
content: Optional[JsonDict] = None,
is_remote_join: bool = False,
) -> EventBase:
"""Updates the membership of a user to the given value.
Expand All @@ -946,6 +948,9 @@ async def update_room_membership(
https://spec.matrix.org/unstable/client-server-api/#mroommember for the
list of allowed values.
content: Additional values to include in the resulting event's content.
is_remote_join: Must be True if room_id refers to a remote room and
new_membership is "join" (i.e. a remote join is needed), otherwise must
be False.
Returns:
The newly created membership event.
Expand Down Expand Up @@ -999,11 +1004,16 @@ async def update_room_membership(
if "displayname" not in content:
content["displayname"] = profile["displayname"]

remote_room_hosts = None
if is_remote_join:
remote_room_hosts = [RoomID.from_string(room_id).domain]

event_id, _ = await self._hs.get_room_member_handler().update_membership(
requester=requester,
target=target_user_id,
room_id=room_id,
action=new_membership,
remote_room_hosts=remote_room_hosts,
content=content,
)

Expand Down

0 comments on commit 6e2b45d

Please sign in to comment.