summary refs log tree commit diff
path: root/synapse/visibility.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2016-08-26 13:41:57 +0100
committerGitHub <noreply@github.com>2016-08-26 13:41:57 +0100
commitc943d8d2e8a08d3ec2cc17a466f8426058fb6246 (patch)
treeff4b826a956b0890727734063b2895c8e61cefbc /synapse/visibility.py
parentMerge pull request #1043 from matrix-org/erikj/backfill_fix (diff)
parentAdd is_host_joined to slave storage (diff)
downloadsynapse-c943d8d2e8a08d3ec2cc17a466f8426058fb6246.tar.xz
Merge pull request #1047 from matrix-org/erikj/state_ids
Avoid pulling the full state of a room out so often.
Diffstat (limited to 'synapse/visibility.py')
-rw-r--r--synapse/visibility.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/visibility.py b/synapse/visibility.py
index cc12c0a23d..199b16d827 100644
--- a/synapse/visibility.py
+++ b/synapse/visibility.py
@@ -181,6 +181,25 @@ def filter_events_for_clients(store, user_tuples, events, event_id_to_state):
 
 
 @defer.inlineCallbacks
+def filter_events_for_clients_context(store, user_tuples, events, event_id_to_context):
+    user_ids = set(u[0] for u in user_tuples)
+    event_id_to_state = {}
+    for event_id, context in event_id_to_context.items():
+        state = yield store.get_events([
+            e_id
+            for key, e_id in context.current_state_ids.iteritems()
+            if key == (EventTypes.RoomHistoryVisibility, "")
+            or (key[0] == EventTypes.Member and key[1] in user_ids)
+        ])
+        event_id_to_state[event_id] = state
+
+    res = yield filter_events_for_clients(
+        store, user_tuples, events, event_id_to_state
+    )
+    defer.returnValue(res)
+
+
+@defer.inlineCallbacks
 def filter_events_for_client(store, user_id, events, is_peeking=False):
     """
     Check which events a user is allowed to see