forked from MirrorHub/synapse
Include invites in incremental sync
This commit is contained in:
parent
ab9cf73258
commit
54414221e4
2 changed files with 26 additions and 7 deletions
|
@ -163,7 +163,7 @@ class SyncHandler(BaseHandler):
|
||||||
invited = []
|
invited = []
|
||||||
for event in room_list:
|
for event in room_list:
|
||||||
if event.membership == Membership.JOIN:
|
if event.membership == Membership.JOIN:
|
||||||
room_sync = yield self.initial_sync_for_room(
|
room_sync = yield self.initial_sync_for_joined_room(
|
||||||
event.room_id, sync_config, now_token,
|
event.room_id, sync_config, now_token,
|
||||||
)
|
)
|
||||||
joined.append(room_sync)
|
joined.append(room_sync)
|
||||||
|
@ -240,9 +240,9 @@ class SyncHandler(BaseHandler):
|
||||||
)
|
)
|
||||||
if app_service:
|
if app_service:
|
||||||
rooms = yield self.store.get_app_service_rooms(app_service)
|
rooms = yield self.store.get_app_service_rooms(app_service)
|
||||||
room_ids = set(r.room_id for r in rooms)
|
joined_room_ids = set(r.room_id for r in rooms)
|
||||||
else:
|
else:
|
||||||
room_ids = yield rm_handler.get_joined_rooms_for_user(
|
joined_room_ids = yield rm_handler.get_joined_rooms_for_user(
|
||||||
sync_config.user
|
sync_config.user
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -260,11 +260,17 @@ class SyncHandler(BaseHandler):
|
||||||
if len(room_events) <= timeline_limit:
|
if len(room_events) <= timeline_limit:
|
||||||
# There is no gap in any of the rooms. Therefore we can just
|
# There is no gap in any of the rooms. Therefore we can just
|
||||||
# partition the new events by room and return them.
|
# partition the new events by room and return them.
|
||||||
|
invite_events = []
|
||||||
events_by_room_id = {}
|
events_by_room_id = {}
|
||||||
for event in room_events:
|
for event in room_events:
|
||||||
events_by_room_id.setdefault(event.room_id, []).append(event)
|
events_by_room_id.setdefault(event.room_id, []).append(event)
|
||||||
|
if event.room_id not in joined_room_ids:
|
||||||
|
if (event.type == EventTypes.Member
|
||||||
|
and event.membership == Membership.INVITE
|
||||||
|
and event.state_key == sync_config.user.to_string()):
|
||||||
|
invite_events.append(event)
|
||||||
|
|
||||||
for room_id in room_ids:
|
for room_id in joined_room_ids:
|
||||||
recents = events_by_room_id.get(room_id, [])
|
recents = events_by_room_id.get(room_id, [])
|
||||||
state = [event for event in recents if event.is_state()]
|
state = [event for event in recents if event.is_state()]
|
||||||
if recents:
|
if recents:
|
||||||
|
@ -291,7 +297,15 @@ class SyncHandler(BaseHandler):
|
||||||
if room_sync:
|
if room_sync:
|
||||||
joined.append(room_sync)
|
joined.append(room_sync)
|
||||||
else:
|
else:
|
||||||
for room_id in room_ids:
|
invites = yield self.store.get_rooms_for_user_where_membership_is(
|
||||||
|
user_id=sync_config.user.to_string(),
|
||||||
|
membership_list=[Membership.INVITE],
|
||||||
|
)
|
||||||
|
invite_events = yield self.store.get_events(
|
||||||
|
[invite.event_id for invite in invites]
|
||||||
|
)
|
||||||
|
|
||||||
|
for room_id in joined_room_ids:
|
||||||
room_sync = yield self.incremental_sync_with_gap_for_room(
|
room_sync = yield self.incremental_sync_with_gap_for_room(
|
||||||
room_id, sync_config, since_token, now_token,
|
room_id, sync_config, since_token, now_token,
|
||||||
typing_by_room
|
typing_by_room
|
||||||
|
@ -299,10 +313,15 @@ class SyncHandler(BaseHandler):
|
||||||
if room_sync:
|
if room_sync:
|
||||||
joined.append(room_sync)
|
joined.append(room_sync)
|
||||||
|
|
||||||
|
invited = [
|
||||||
|
InvitedSyncResult(room_id=event.room_id, invite=event)
|
||||||
|
for event in invite_events
|
||||||
|
]
|
||||||
|
|
||||||
defer.returnValue(SyncResult(
|
defer.returnValue(SyncResult(
|
||||||
presence=presence,
|
presence=presence,
|
||||||
joined=joined,
|
joined=joined,
|
||||||
invited=[],
|
invited=invited,
|
||||||
next_batch=now_token,
|
next_batch=now_token,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue