summary refs log tree commit diff
path: root/synapse/federation
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-11-10 11:59:51 +0000
committerErik Johnston <erik@matrix.org>2014-11-10 11:59:51 +0000
commit6447db063a0d01135582bdfb3392b419f16a19e7 (patch)
tree6f94306775c4344dd695e4b6bb64776ca94bd8de /synapse/federation
parentNotify users about invites. (diff)
downloadsynapse-6447db063a0d01135582bdfb3392b419f16a19e7.tar.xz
Fix backfill to work. Add auth to backfill request
Diffstat (limited to 'synapse/federation')
-rw-r--r--synapse/federation/replication.py36
-rw-r--r--synapse/federation/transport.py6
2 files changed, 31 insertions, 11 deletions
diff --git a/synapse/federation/replication.py b/synapse/federation/replication.py
index 719bfcc42c..7837f1c252 100644
--- a/synapse/federation/replication.py
+++ b/synapse/federation/replication.py
@@ -205,7 +205,7 @@ class ReplicationLayer(object):
 
         pdus = [Pdu(outlier=False, **p) for p in transaction.pdus]
         for pdu in pdus:
-            yield self._handle_new_pdu(pdu, backfilled=True)
+            yield self._handle_new_pdu(dest, pdu, backfilled=True)
 
         defer.returnValue(pdus)
 
@@ -274,9 +274,9 @@ class ReplicationLayer(object):
 
     @defer.inlineCallbacks
     @log_function
-    def on_backfill_request(self, context, versions, limit):
+    def on_backfill_request(self, origin, context, versions, limit):
         pdus = yield self.handler.on_backfill_request(
-            context, versions, limit
+            origin, context, versions, limit
         )
 
         defer.returnValue((200, self._transaction_from_pdus(pdus).get_dict()))
@@ -408,13 +408,22 @@ class ReplicationLayer(object):
     @defer.inlineCallbacks
     def on_make_join_request(self, context, user_id):
         pdu = yield self.handler.on_make_join_request(context, user_id)
-        defer.returnValue(pdu.get_dict())
+        defer.returnValue({
+            "event": pdu.get_dict(),
+        })
 
     @defer.inlineCallbacks
     def on_invite_request(self, origin, content):
         pdu = Pdu(**content)
         ret_pdu = yield self.handler.on_invite_request(origin, pdu)
-        defer.returnValue((200, ret_pdu.get_dict()))
+        defer.returnValue(
+            (
+                200,
+                {
+                    "event": ret_pdu.get_dict(),
+                }
+            )
+        )
 
     @defer.inlineCallbacks
     def on_send_join_request(self, origin, content):
@@ -429,16 +438,25 @@ class ReplicationLayer(object):
     @defer.inlineCallbacks
     def on_event_auth(self, origin, context, event_id):
         auth_pdus = yield self.handler.on_event_auth(event_id)
-        defer.returnValue((200, [a.get_dict() for a in auth_pdus]))
+        defer.returnValue(
+            (
+                200,
+                {
+                    "auth_chain": [a.get_dict() for a in auth_pdus],
+                }
+            )
+        )
 
     @defer.inlineCallbacks
     def make_join(self, destination, context, user_id):
-        pdu_dict = yield self.transport_layer.make_join(
+        ret = yield self.transport_layer.make_join(
             destination=destination,
             context=context,
             user_id=user_id,
         )
 
+        pdu_dict = ret["event"]
+
         logger.debug("Got response to make_join: %s", pdu_dict)
 
         defer.returnValue(Pdu(**pdu_dict))
@@ -467,13 +485,15 @@ class ReplicationLayer(object):
 
     @defer.inlineCallbacks
     def send_invite(self, destination, context, event_id, pdu):
-        code, pdu_dict = yield self.transport_layer.send_invite(
+        code, content = yield self.transport_layer.send_invite(
             destination=destination,
             context=context,
             event_id=event_id,
             content=pdu.get_dict(),
         )
 
+        pdu_dict = content["event"]
+
         logger.debug("Got response to send_invite: %s", pdu_dict)
 
         defer.returnValue(Pdu(**pdu_dict))
diff --git a/synapse/federation/transport.py b/synapse/federation/transport.py
index babe8447eb..92a1f4ce17 100644
--- a/synapse/federation/transport.py
+++ b/synapse/federation/transport.py
@@ -413,7 +413,7 @@ class TransportLayer(object):
             self._with_authentication(
                 lambda origin, content, query, context:
                 self._on_backfill_request(
-                    context, query["v"], query["limit"]
+                    origin, context, query["v"], query["limit"]
                 )
             )
         )
@@ -552,7 +552,7 @@ class TransportLayer(object):
         defer.returnValue(data)
 
     @log_function
-    def _on_backfill_request(self, context, v_list, limits):
+    def _on_backfill_request(self, origin, context, v_list, limits):
         if not limits:
             return defer.succeed(
                 (400, {"error": "Did not include limit param"})
@@ -563,7 +563,7 @@ class TransportLayer(object):
         versions = v_list
 
         return self.request_handler.on_backfill_request(
-            context, versions, limit
+            origin, context, versions, limit
         )
 
     @defer.inlineCallbacks