summary refs log tree commit diff
path: root/synapse/handlers/room_member_worker.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-11-11 17:41:57 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2020-11-13 16:22:56 +0000
commita4dafd407df25ea9bedd840db2c9c886904bb46f (patch)
treee4e0124fad8764b52454e5ba50a37592e59f383c /synapse/handlers/room_member_worker.py
parentRename maybe_store_room_on_{invite,outlier_membership} (diff)
downloadsynapse-a4dafd407df25ea9bedd840db2c9c886904bb46f.tar.xz
Federation: make_knock and send_knock implementations
Most of this is explained in the linked MSC (and don't miss the sequence
diagram in the MSC comments), but roughly knocking takes inspiration from
room joins and room invites. This commit is the room join stuff.

First the knocking homeserver POSTs to the make_knock endpoint on
another homeserver. The other homeserver will send back a knock event
that is valid for the knocking user and the room that they are knocking
on. The knocking homeserver will sign the event and send it back, before
the other homeserver takes that event and then sends it into the room on
the knocking homeserver's behalf.

It's worth noting that the accepting/rejecting knocks all happen over
existing room invite/leave flows. A homeserver rescinding its knock as
well is also just sending a leave.

Once the event has been inserted into the room, the homeserver that's in
the room will send back a 200 and an empty JSON dict to confirm
everything went well to the knocker. In a future commit, this dict will
instead be filled with some stripped state events from the room which
the knocking homeserver will pass back to the knocking user.

And yes, the logging statements in this commit are intentional. They're
consistent with the rest of the file :)
Diffstat (limited to '')
-rw-r--r--synapse/handlers/room_member_worker.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/synapse/handlers/room_member_worker.py b/synapse/handlers/room_member_worker.py
index f2e88f6a5b..f9cea604ec 100644
--- a/synapse/handlers/room_member_worker.py
+++ b/synapse/handlers/room_member_worker.py
@@ -79,6 +79,20 @@ class RoomMemberWorkerHandler(RoomMemberHandler):
         )
         return ret["event_id"], ret["stream_id"]
 
+    async def _remote_knock(
+        self, remote_room_hosts: List[str], room_id: str, user: UserID, content: dict,
+    ) -> Tuple[str, int]:
+        """Sends a knock to a room.
+
+        Implements RoomMemberHandler._remote_knock
+        """
+        return await self._remote_knock(
+            remote_room_hosts=remote_room_hosts,
+            room_id=room_id,
+            user=user,
+            content=content,
+        )
+
     async def _user_left_room(self, target: UserID, room_id: str) -> None:
         """Implements RoomMemberHandler._user_left_room
         """