summary refs log tree commit diff
diff options
context:
space:
mode:
authorMathieu Velten <mathieuv@matrix.org>2023-01-26 15:56:10 +0100
committerMathieu Velten <mathieuv@matrix.org>2023-01-26 15:56:49 +0100
commit5009830cb27b98542121ad403bab813758b66707 (patch)
tree6d5222faf4e3a7b4dd59aa6941c2bdc8744ffa92
parentRun `black` (diff)
downloadsynapse-mv/batch-partial-states-lookups-more.tar.xz
-rw-r--r--synapse/visibility.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/synapse/visibility.py b/synapse/visibility.py
index e442de3173..f523b6a329 100644
--- a/synapse/visibility.py
+++ b/synapse/visibility.py
@@ -631,15 +631,18 @@ async def filter_events_for_server(
     # otherwise a room could be fully joined after we retrieve those, which would then bypass
     # this check but would base the filtering on an outdated view of the membership events.
 
-    partial_state_invisible_events = set()
+    partial_stated_room_ids = set()
     if not check_history_visibility_only:
+        room_ids_to_check: List[str] = []
         for e in events:
             sender_domain = get_domain_from_id(e.sender)
-            if (
-                sender_domain != local_server_name
-                and await storage.main.is_partial_state_room(e.room_id)
-            ):
-                partial_state_invisible_events.add(e)
+            if sender_domain != local_server_name:
+                room_ids_to_check.append(e.room_id)
+
+        results = await storage.main.is_partial_state_room_batched(room_ids_to_check)
+        for room_id, is_partial_state in results.items():
+            if is_partial_state:
+                partial_stated_room_ids.add(room_id)
 
     # Let's check to see if all the events have a history visibility
     # of "shared" or "world_readable". If that's the case then we don't
@@ -665,7 +668,7 @@ async def filter_events_for_server(
             event_to_history_vis[e.event_id], event_to_memberships.get(e.event_id, {})
         )
 
-        if e in partial_state_invisible_events:
+        if e.room_id in partial_stated_room_ids:
             visible = False
 
         if visible and not erased: