summary refs log tree commit diff
path: root/synapse/federation
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-01-28 16:16:53 +0000
committerErik Johnston <erik@matrix.org>2015-01-28 16:16:53 +0000
commit0ef5bfd6a9eaaae14e199997658b3d0006abd854 (patch)
tree5c0a35bbe563e860673e3fb771306d48bce6392a /synapse/federation
parentMake it the responsibility of the replication layer to check signature and ha... (diff)
downloadsynapse-0ef5bfd6a9eaaae14e199997658b3d0006abd854.tar.xz
Start implementing auth conflict res
Diffstat (limited to 'synapse/federation')
-rw-r--r--synapse/federation/federation_client.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py
index 91b44cd8b3..ebcd593506 100644
--- a/synapse/federation/federation_client.py
+++ b/synapse/federation/federation_client.py
@@ -331,6 +331,45 @@ class FederationClient(object):
 
         defer.returnValue(pdu)
 
+    @defer.inlineCallbacks
+    def query_auth(self, destination, room_id, event_id, local_auth):
+        """
+        Params:
+            destination (str)
+            event_it (str)
+            local_auth (list)
+        """
+        time_now = self._clock.time_msec()
+
+        send_content = {
+            "auth_chain": [e.get_pdu_json(time_now) for e in local_auth],
+        }
+
+        code, content = yield self.transport_layer.send_invite(
+            destination=destination,
+            room_id=room_id,
+            event_id=event_id,
+            content=send_content,
+        )
+
+        auth_chain = [
+            (yield self._check_sigs_and_hash(self.event_from_pdu_json(e)))
+            for e in content["auth_chain"]
+        ]
+
+        missing = [
+            (yield self._check_sigs_and_hash(self.event_from_pdu_json(e)))
+            for e in content.get("missing", [])
+        ]
+
+        ret = {
+            "auth_chain": auth_chain,
+            "rejects": content.get("rejects", []),
+            "missing": missing,
+        }
+
+        defer.returnValue(ret)
+
     def event_from_pdu_json(self, pdu_json, outlier=False):
         event = FrozenEvent(
             pdu_json