diff options
author | David Baker <dave@matrix.org> | 2016-01-20 13:33:45 +0000 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2016-01-20 13:33:45 +0000 |
commit | ccf9387d57ba57e3b996b48134cfac8142a19cbe (patch) | |
tree | d58abd587b00c88dcc6ec127df68f0d29d5cb112 /synapse/handlers/_base.py | |
parent | Merge branch 'develop' into push_badge_counts (diff) | |
parent | Merge pull request #506 from matrix-org/erikj/push_fast (diff) | |
download | synapse-ccf9387d57ba57e3b996b48134cfac8142a19cbe.tar.xz |
Merge branch 'develop' into push_badge_counts
Diffstat (limited to 'synapse/handlers/_base.py')
-rw-r--r-- | synapse/handlers/_base.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py index 5c7617de44..46abb8ec51 100644 --- a/synapse/handlers/_base.py +++ b/synapse/handlers/_base.py @@ -53,16 +53,23 @@ class BaseHandler(object): self.event_builder_factory = hs.get_event_builder_factory() @defer.inlineCallbacks - def _filter_events_for_clients(self, users, events): + def _filter_events_for_clients(self, user_tuples, events): """ Returns dict of user_id -> list of events that user is allowed to see. """ - event_id_to_state = yield self.store.get_state_for_events( - frozenset(e.event_id for e in events), - types=( + # If there is only one user, just get the state for that one user, + # otherwise just get all the state. + if len(user_tuples) == 1: + types = ( (EventTypes.RoomHistoryVisibility, ""), - (EventTypes.Member, None), + (EventTypes.Member, user_tuples[0][0]), ) + else: + types = None + + event_id_to_state = yield self.store.get_state_for_events( + frozenset(e.event_id for e in events), + types=types ) forgotten = yield defer.gatherResults([ @@ -122,7 +129,7 @@ class BaseHandler(object): for event in events if allowed(event, user_id, is_guest) ] - for user_id, is_guest in users + for user_id, is_guest in user_tuples }) @defer.inlineCallbacks |