summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2025-06-08 23:14:31 +0200
committerRory& <root@rory.gay>2025-06-27 19:46:32 +0200
commit6eb23d3018f68744ba363fb7a89a9a4982d67a19 (patch)
treed0e17c20c4dbd02a71a07967287c390af650e646
parentfix: Always recheck `/messages` pagination data if a backfill might have been... (diff)
downloadsynapse-6eb23d3018f68744ba363fb7a89a9a4982d67a19.tar.xz
Fix pagination with large gaps of rejected events
-rw-r--r--synapse/handlers/pagination.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/synapse/handlers/pagination.py b/synapse/handlers/pagination.py

index 81cda38549..365c9cabcb 100644 --- a/synapse/handlers/pagination.py +++ b/synapse/handlers/pagination.py
@@ -510,7 +510,7 @@ class PaginationHandler: ( events, next_key, - _, + limited, ) = await self.store.paginate_room_events_by_topological_ordering( room_id=room_id, from_key=from_token.room_key, @@ -593,7 +593,7 @@ class PaginationHandler: ( events, next_key, - _, + limited, ) = await self.store.paginate_room_events_by_topological_ordering( room_id=room_id, from_key=from_token.room_key, @@ -616,6 +616,15 @@ class PaginationHandler: next_token = from_token.copy_and_replace(StreamKeyType.ROOM, next_key) + # We might have hit some internal filtering first, for example rejected + # events. Ensure we return a pagination token then. + if not events and limited: + return { + "chunk": [], + "start": await from_token.to_string(self.store), + "end": await next_token.to_string(self.store), + } + # if no events are returned from pagination, that implies # we have reached the end of the available events. # In that case we do not return end, to tell the client