summary refs log tree commit diff
path: root/synapse/handlers/federation.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-11-11 18:10:40 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2020-11-13 16:23:00 +0000
commit09e1942b04ddc800a62a5872e151c981a0339261 (patch)
tree1d21f554a836d642d7f6d8431f786aeb9e67caa2 /synapse/handlers/federation.py
parentFederation: make_knock and send_knock implementations (diff)
downloadsynapse-09e1942b04ddc800a62a5872e151c981a0339261.tar.xz
Send stripped state events back to the knocking homeserver
Here we finally send the stripped state events back to the knocking
homeserver, which then ingests and stores those events.

A future commit will actually start sending those events down /sync to
the relevant user.
Diffstat (limited to '')
-rw-r--r--synapse/handlers/federation.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index c89b5d61d4..377180886f 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -1484,10 +1484,18 @@ class FederationHandler(BaseHandler):
         except ValueError:
             pass
 
-        # Send the signed event back to the room
-        await self.federation_client.send_knock(target_hosts, event)
+        # Send the signed event back to the room, and potentially receive some
+        # further information about the room in the form of partial state events
+        stripped_room_state = await self.federation_client.send_knock(
+            target_hosts, event
+        )
+
+        # Store any stripped room state events in the "unsigned" key of the event.
+        # This is a bit of a hack and is cribbing off of invites. Basically we
+        # store the room state here and retrieve it again when this event appears
+        # in the invitee's sync stream. It is stripped out for all other local users.
+        event.unsigned["knock_room_state"] = stripped_room_state["knock_state_events"]
 
-        # Store the event locally
         context = await self.state_handler.compute_event_context(event)
         stream_id = await self.persist_events_and_notify(
             event.room_id, [(event, context)]