summary refs log tree commit diff
path: root/synapse/handlers/federation.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-11-07 13:41:00 +0000
committerErik Johnston <erik@matrix.org>2014-11-07 13:41:00 +0000
commitd2fb2b8095ec7f5d00b51418e84b05a1b23b79b3 (patch)
treec30e569f38d087093b4a867012ca89c2370c064f /synapse/handlers/federation.py
parentRemove /context/ request (diff)
downloadsynapse-d2fb2b8095ec7f5d00b51418e84b05a1b23b79b3.tar.xz
Implement invite part of invite join dance
Diffstat (limited to 'synapse/handlers/federation.py')
-rw-r--r--synapse/handlers/federation.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index c193da12b7..e6afd95a58 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -23,6 +23,7 @@ from synapse.api.constants import Membership
 from synapse.util.logutils import log_function
 from synapse.federation.pdu_codec import PduCodec
 from synapse.util.async import run_on_reactor
+from synapse.crypto.event_signing import compute_event_signature
 
 from twisted.internet import defer
 
@@ -212,6 +213,17 @@ class FederationHandler(BaseHandler):
 
         defer.returnValue(events)
 
+    @defer.inlineCallbacks
+    def send_invite(self, target_host, event):
+        pdu = yield self.replication_layer.send_invite(
+            destination=target_host,
+            context=event.room_id,
+            event_id=event.event_id,
+            pdu=self.pdu_codec.pdu_from_event(event)
+        )
+
+        defer.returnValue(self.pdu_codec.event_from_pdu(pdu))
+
     @log_function
     @defer.inlineCallbacks
     def do_invite_join(self, target_host, room_id, joinee, content, snapshot):
@@ -381,6 +393,31 @@ class FederationHandler(BaseHandler):
         })
 
     @defer.inlineCallbacks
+    def on_invite_request(self, origin, pdu):
+        event = self.pdu_codec.event_from_pdu(pdu)
+
+        event.outlier = True
+
+        event.signatures.update(
+            compute_event_signature(
+                event,
+                self.hs.hostname,
+                self.hs.config.signing_key[0]
+            )
+        )
+
+        yield self.state_handler.annotate_state_groups(event)
+
+        yield self.store.persist_event(
+            event,
+            backfilled=False,
+        )
+
+        yield self.notifier.on_new_room_event(event)
+
+        defer.returnValue(self.pdu_codec.pdu_from_event(event))
+
+    @defer.inlineCallbacks
     def get_state_for_pdu(self, event_id):
         yield run_on_reactor()