summary refs log tree commit diff
path: root/synapse/handlers/sync.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-10-16 14:52:48 +0100
committerErik Johnston <erik@matrix.org>2015-10-16 14:52:48 +0100
commit366af6b73a02dc85cd59ee17cc2eafb912d221e8 (patch)
tree0601eb57ef9246c35995f20eadb64da09a9ec559 /synapse/handlers/sync.py
parentMerge pull request #308 from matrix-org/markjh/v2_filter_encoding (diff)
downloadsynapse-366af6b73a02dc85cd59ee17cc2eafb912d221e8.tar.xz
Amalgamate _filter_events_for_client
Diffstat (limited to 'synapse/handlers/sync.py')
-rw-r--r--synapse/handlers/sync.py48
1 files changed, 1 insertions, 47 deletions
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index 21cf50101a..ee6b881de1 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -322,52 +322,6 @@ class SyncHandler(BaseHandler):
         ))
 
     @defer.inlineCallbacks
-    def _filter_events_for_client(self, user_id, room_id, events):
-        event_id_to_state = yield self.store.get_state_for_events(
-            frozenset(e.event_id for e in events),
-            types=(
-                (EventTypes.RoomHistoryVisibility, ""),
-                (EventTypes.Member, user_id),
-            )
-        )
-
-        def allowed(event, state):
-            if event.type == EventTypes.RoomHistoryVisibility:
-                return True
-
-            membership_ev = state.get((EventTypes.Member, user_id), None)
-            if membership_ev:
-                membership = membership_ev.membership
-            else:
-                membership = Membership.LEAVE
-
-            if membership == Membership.JOIN:
-                return True
-
-            history = state.get((EventTypes.RoomHistoryVisibility, ''), None)
-            if history:
-                visibility = history.content.get("history_visibility", "shared")
-            else:
-                visibility = "shared"
-
-            if visibility == "public":
-                return True
-            elif visibility == "shared":
-                return True
-            elif visibility == "joined":
-                return membership == Membership.JOIN
-            elif visibility == "invited":
-                return membership == Membership.INVITE
-
-            return True
-
-        defer.returnValue([
-            event
-            for event in events
-            if allowed(event, event_id_to_state[event.event_id])
-        ])
-
-    @defer.inlineCallbacks
     def load_filtered_recents(self, room_id, sync_config, now_token,
                               since_token=None):
         limited = True
@@ -390,7 +344,7 @@ class SyncHandler(BaseHandler):
             end_key = "s" + room_key.split('-')[-1]
             loaded_recents = sync_config.filter.filter_room_timeline(events)
             loaded_recents = yield self._filter_events_for_client(
-                sync_config.user.to_string(), room_id, loaded_recents,
+                sync_config.user.to_string(), loaded_recents,
             )
             loaded_recents.extend(recents)
             recents = loaded_recents