summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-04-01 13:10:07 +0100
committerErik Johnston <erik@matrix.org>2016-04-01 13:14:53 +0100
commit35bb465b8698cb3ed9d034563d3b9ee03579e775 (patch)
tree042fd22ceb10660c5b231dbb91d64a3bde3f65ad
parentMerge pull request #682 from matrix-org/markjh/fix_invalidate (diff)
downloadsynapse-35bb465b8698cb3ed9d034563d3b9ee03579e775.tar.xz
Filter rooms list before chunking
Diffstat (limited to '')
-rw-r--r--synapse/handlers/sync.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index 48ab5707e1..06098f899e 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -252,6 +252,18 @@ class SyncHandler(BaseHandler):
         archived = []
         deferreds = []
 
+        user_id = sync_config.user.to_string()
+
+        def _should_include_room(event):
+            # Always send down rooms we were banned or kicked from.
+            if not sync_config.filter_collection.include_leave:
+                if event.membership == Membership.LEAVE:
+                    if user_id == event.sender:
+                        return False
+            return True
+
+        room_list = filter(_should_include_room, room_list)
+
         room_list_chunks = [room_list[i:i + 10] for i in xrange(0, len(room_list), 10)]
         for room_list_chunk in room_list_chunks:
             for event in room_list_chunk:
@@ -276,12 +288,6 @@ class SyncHandler(BaseHandler):
                         invite=invite,
                     ))
                 elif event.membership in (Membership.LEAVE, Membership.BAN):
-                    # Always send down rooms we were banned or kicked from.
-                    if not sync_config.filter_collection.include_leave:
-                        if event.membership == Membership.LEAVE:
-                            if sync_config.user.to_string() == event.sender:
-                                continue
-
                     leave_token = now_token.copy_and_replace(
                         "room_key", "s%d" % (event.stream_ordering,)
                     )