summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2024-07-12 14:03:56 +0100
committerErik Johnston <erik@matrix.org>2024-07-12 14:03:56 +0100
commitf05bb135d3d9405e8a06554c054b7b6dd6d1ad40 (patch)
tree8d29b326c63eeed427e6e4ff2d374e1c5d6c1c04
parentMerge remote-tracking branch 'origin/develop' into erikj/ss_hacks (diff)
downloadsynapse-f05bb135d3d9405e8a06554c054b7b6dd6d1ad40.tar.xz
Have more timeline events in incremental syncs
-rw-r--r--synapse/handlers/sliding_sync.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/synapse/handlers/sliding_sync.py b/synapse/handlers/sliding_sync.py
index df7f7989be..0dc4f56778 100644
--- a/synapse/handlers/sliding_sync.py
+++ b/synapse/handlers/sliding_sync.py
@@ -1261,6 +1261,10 @@ class SlidingSyncHandler:
                 else None
             )
 
+            fiddled_timeline_limit = room_sync_config.timeline_limit
+            if to_bound:
+                fiddled_timeline_limit = max(fiddled_timeline_limit, 10)
+
             timeline_events, new_room_key = await self.store.paginate_room_events(
                 room_id=room_id,
                 from_key=from_bound,
@@ -1268,7 +1272,7 @@ class SlidingSyncHandler:
                 direction=Direction.BACKWARDS,
                 # We add one so we can determine if there are enough events to saturate
                 # the limit or not (see `limited`)
-                limit=room_sync_config.timeline_limit + 1,
+                limit=fiddled_timeline_limit + 1,
                 event_filter=None,
             )
 
@@ -1279,11 +1283,11 @@ class SlidingSyncHandler:
             # Determine our `limited` status based on the timeline. We do this before
             # filtering the events so we can accurately determine if there is more to
             # paginate even if we filter out some/all events.
-            if len(timeline_events) > room_sync_config.timeline_limit:
+            if len(timeline_events) > fiddled_timeline_limit:
                 limited = True
                 # Get rid of that extra "+ 1" event because we only used it to determine
                 # if we hit the limit or not
-                timeline_events = timeline_events[-room_sync_config.timeline_limit :]
+                timeline_events = timeline_events[-fiddled_timeline_limit:]
                 assert timeline_events[0].internal_metadata.stream_ordering
                 new_room_key = RoomStreamToken(
                     stream=timeline_events[0].internal_metadata.stream_ordering - 1