diff options
author | Erik Johnston <erikj@element.io> | 2024-04-09 15:01:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-09 14:01:12 +0000 |
commit | 89f1092284c4a171918179a87fdd488b003c86b9 (patch) | |
tree | a1cd6f6e697167e8a35701637f2ba5eeafd7b665 /synapse/handlers/sync.py | |
parent | #17039 Issue: Update base_rules.rs (#17043) (diff) | |
download | synapse-89f1092284c4a171918179a87fdd488b003c86b9.tar.xz |
Also check if first event matches the last in prev batch (#17066)
Refinement of #17064 cc @richvdh
Diffstat (limited to 'synapse/handlers/sync.py')
-rw-r--r-- | synapse/handlers/sync.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index 410805e806..a6d54ee4b8 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -1266,17 +1266,23 @@ class SyncHandler: # # c.f. #16941 for an example of why we can't do this for all non-gappy # syncs. - is_linear_timeline = False + is_linear_timeline = True if batch.events: - prev_event_id = batch.events[0].event_id - for e in batch.events[1:]: + # We need to make sure the first event in our batch points to the + # last event in the previous batch. + last_event_id_prev_batch = ( + await self.store.get_last_event_in_room_before_stream_ordering( + room_id, + end_token=since_token.room_key, + ) + ) + + prev_event_id = last_event_id_prev_batch + for e in batch.events: if e.prev_event_ids() != [prev_event_id]: + is_linear_timeline = False break prev_event_id = e.event_id - else: - is_linear_timeline = True - else: - is_linear_timeline = True if is_linear_timeline and not batch.limited: state_ids: StateMap[str] = {} |