summary refs log tree commit diff
path: root/synapse/handlers/federation.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-02-20 15:41:08 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2020-02-20 15:41:08 +0000
commitd478a36ae473963f43452d16a5fc245fc3fd9784 (patch)
tree4edb5da471870f8033523a5b3674ca0b803cddae /synapse/handlers/federation.py
parentMerge pull request #5774 from matrix-org/erikj/fix_rejected_membership (diff)
parentRoom Complexity Client Implementation (#5783) (diff)
downloadsynapse-d478a36ae473963f43452d16a5fc245fc3fd9784.tar.xz
Room Complexity Client Implementation (#5783)
Diffstat (limited to 'synapse/handlers/federation.py')
-rw-r--r--synapse/handlers/federation.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index 319ee35d9a..ba1f4826a4 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -2808,3 +2808,28 @@ class FederationHandler(BaseHandler):
             )
         else:
             return user_joined_room(self.distributor, user, room_id)
+
+    @defer.inlineCallbacks
+    def get_room_complexity(self, remote_room_hosts, room_id):
+        """
+        Fetch the complexity of a remote room over federation.
+
+        Args:
+            remote_room_hosts (list[str]): The remote servers to ask.
+            room_id (str): The room ID to ask about.
+
+        Returns:
+            Deferred[dict] or Deferred[None]: Dict contains the complexity
+            metric versions, while None means we could not fetch the complexity.
+        """
+
+        for host in remote_room_hosts:
+            res = yield self.federation_client.get_room_complexity(host, room_id)
+
+            # We got a result, return it.
+            if res:
+                defer.returnValue(res)
+
+        # We fell off the bottom, couldn't get the complexity from anyone. Oh
+        # well.
+        defer.returnValue(None)