summary refs log tree commit diff
path: root/packages/overlays/matrix-synapse/patches/0009-Fix-pagination-with-large-gaps-of-rejected-events.patch
blob: ebed62e6394967b411eede0251425c49875611d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From 2f2dd65326b8a8dc6b7ac99dbe7476abb2163469 Mon Sep 17 00:00:00 2001
From: Nicolas Werner <nicolas.werner@hotmail.de>
Date: Sun, 8 Jun 2025 23:14:31 +0200
Subject: [PATCH 09/11] Fix pagination with large gaps of rejected events

---
 synapse/handlers/pagination.py | 13 +++++++++++--
 1 file 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
-- 
2.49.0