add state_ids for timeline entries

This commit is contained in:
Matthew Hodgson 2018-03-16 01:37:53 +00:00
parent 5b3b3aada8
commit f7dcc404f2
1 changed files with 14 additions and 4 deletions

View File

@ -474,6 +474,7 @@ class SyncHandler(object):
if filter_members: if filter_members:
# We only request state for the members needed to display the # We only request state for the members needed to display the
# timeline: # timeline:
types = [ types = [
(EventTypes.Member, state_key) (EventTypes.Member, state_key)
for state_key in set( for state_key in set(
@ -481,11 +482,14 @@ class SyncHandler(object):
for event in batch.events for event in batch.events
) )
] ]
types.append((None, None)) # don't just filter to room members
# TODO: we should opportunistically deduplicate these members too # TODO: we should opportunistically deduplicate these members here
# within the same sync series (based on an in-memory cache) # within the same sync series (based on an in-memory cache)
if not types:
filter_members = False
types.append((None, None)) # don't just filter to room members
if full_state: if full_state:
if batch: if batch:
current_state_ids = yield self.store.get_state_ids_for_event( current_state_ids = yield self.store.get_state_ids_for_event(
@ -545,7 +549,6 @@ class SyncHandler(object):
} }
logger.info("Found members %r", member_state_ids) logger.info("Found members %r", member_state_ids)
timeline_state = { timeline_state = {
(event.type, event.state_key): event.event_id (event.type, event.state_key): event.event_id
for event in batch.events if event.is_state() for event in batch.events if event.is_state()
@ -558,6 +561,13 @@ class SyncHandler(object):
previous=state_at_previous_sync, previous=state_at_previous_sync,
current=current_state_ids, current=current_state_ids,
) )
else:
if filter_members:
# strip off the (None, None) and filter to just room members
types = types[:-1]
state_ids = yield self.store.get_state_ids_for_event(
batch.events[0].event_id, types=types
)
else: else:
state_ids = {} state_ids = {}