summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-08-26 11:13:16 +0100
committerErik Johnston <erik@matrix.org>2016-08-26 11:13:16 +0100
commitf6338d6a3ee24ffe0fd9e766905d9c4fdc6ea090 (patch)
tree80753124ebb2c3919fab8fe1dae0b86a74457714
parentCache check_host_in_room (diff)
downloadsynapse-f6338d6a3ee24ffe0fd9e766905d9c4fdc6ea090.tar.xz
Don't pull out full state for _filter_events_for_server
-rw-r--r--synapse/handlers/federation.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index a6642ff232..c9deb52280 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -237,7 +237,7 @@ class FederationHandler(BaseHandler):
 
     @defer.inlineCallbacks
     def _filter_events_for_server(self, server_name, room_id, events):
-        event_to_state = yield self.store.get_state_for_events(
+        event_to_state_ids = yield self.store.get_state_ids_for_events(
             frozenset(e.event_id for e in events),
             types=(
                 (EventTypes.RoomHistoryVisibility, ""),
@@ -245,6 +245,30 @@ class FederationHandler(BaseHandler):
             )
         )
 
+        # We only want to pull out member events that correspond to the
+        # server's domain.
+
+        def check_match(id):
+            try:
+                return server_name == get_domain_from_id(id)
+            except:
+                return False
+
+        event_map = yield self.store.get_events([
+            e_id for key_to_eid in event_to_state_ids.values()
+            for key, e_id in key_to_eid
+            if key[0] != EventTypes.Member or check_match(key[1])
+        ])
+
+        event_to_state = {
+            e_id: {
+                key: event_map[inner_e_id]
+                for key, inner_e_id in key_to_eid.items()
+                if inner_e_id in event_map
+            }
+            for e_id, key_to_eid in event_to_state_ids.items()
+        }
+
         def redact_disallowed(event, state):
             if not state:
                 return event