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

Commit 6e2b45d

Browse files
committed
Add - remote join capability to the module API "update_room_membership" method,
in a backwards compatible manner.
1 parent 1c910e2 commit 6e2b45d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

synapse/module_api/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
JsonMapping,
118118
Requester,
119119
RoomAlias,
120+
RoomID,
120121
StateMap,
121122
UserID,
122123
UserInfo,
@@ -929,6 +930,7 @@ async def update_room_membership(
929930
room_id: str,
930931
new_membership: str,
931932
content: Optional[JsonDict] = None,
933+
is_remote_join: bool = False,
932934
) -> EventBase:
933935
"""Updates the membership of a user to the given value.
934936
@@ -946,6 +948,9 @@ async def update_room_membership(
946948
https://spec.matrix.org/unstable/client-server-api/#mroommember for the
947949
list of allowed values.
948950
content: Additional values to include in the resulting event's content.
951+
is_remote_join: Must be True if room_id refers to a remote room and
952+
new_membership is "join" (i.e. a remote join is needed), otherwise must
953+
be False.
949954
950955
Returns:
951956
The newly created membership event.
@@ -999,11 +1004,16 @@ async def update_room_membership(
9991004
if "displayname" not in content:
10001005
content["displayname"] = profile["displayname"]
10011006

1007+
remote_room_hosts = None
1008+
if is_remote_join:
1009+
remote_room_hosts = [RoomID.from_string(room_id).domain]
1010+
10021011
event_id, _ = await self._hs.get_room_member_handler().update_membership(
10031012
requester=requester,
10041013
target=target_user_id,
10051014
room_id=room_id,
10061015
action=new_membership,
1016+
remote_room_hosts=remote_room_hosts,
10071017
content=content,
10081018
)
10091019

0 commit comments

Comments
 (0)