Don't use form of get_state_for_events with None state_key

This commit is contained in:
Erik Johnston 2016-01-19 17:12:46 +00:00
parent 40d9765123
commit 892ee473d9

View File

@ -53,16 +53,23 @@ class BaseHandler(object):
self.event_builder_factory = hs.get_event_builder_factory() self.event_builder_factory = hs.get_event_builder_factory()
@defer.inlineCallbacks @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 """ Returns dict of user_id -> list of events that user is allowed to
see. see.
""" """
event_id_to_state = yield self.store.get_state_for_events( # If there is only one user, just get the state for that one user,
frozenset(e.event_id for e in events), # otherwise just get all the state.
if len(user_tuples) == 1:
types = ( types = (
(EventTypes.RoomHistoryVisibility, ""), (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([ forgotten = yield defer.gatherResults([
@ -122,7 +129,7 @@ class BaseHandler(object):
for event in events for event in events
if allowed(event, user_id, is_guest) if allowed(event, user_id, is_guest)
] ]
for user_id, is_guest in users for user_id, is_guest in user_tuples
}) })
@defer.inlineCallbacks @defer.inlineCallbacks