summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-12-01 16:36:46 +0000
committerErik Johnston <erik@matrix.org>2015-12-01 16:47:18 +0000
commit27c5e1b37442e310aa71d997478f8e61bce1672c (patch)
tree7e7b41fb0de2871b98035dc77d6d14344edeb653 /synapse/handlers
parentMerge pull request #404 from matrix-org/markjh/trivial_rename (diff)
downloadsynapse-27c5e1b37442e310aa71d997478f8e61bce1672c.tar.xz
Search: Don't disregard grouping info in pagination tokens
Diffstat (limited to '')
-rw-r--r--synapse/handlers/search.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/synapse/handlers/search.py b/synapse/handlers/search.py
index df6390cf05..65ef2f85bf 100644
--- a/synapse/handlers/search.py
+++ b/synapse/handlers/search.py
@@ -240,9 +240,18 @@ class SearchHandler(BaseHandler):
                 last_event_id = room_events[-1].event_id
                 pagination_token = results_map[last_event_id]["pagination_token"]
 
-                global_next_batch = encode_base64("%s\n%s\n%s" % (
-                    "all", "", pagination_token
-                ))
+                # We want to respect the given batch group and group keys so
+                # that if people blindly use the top level `next_batch` token
+                # it returns more from the same group (if applicable) rather
+                # than reverting to searching all results again.
+                if batch_group and batch_group_key:
+                    global_next_batch = encode_base64("%s\n%s\n%s" % (
+                        batch_group, batch_group_key, pagination_token
+                    ))
+                else:
+                    global_next_batch = encode_base64("%s\n%s\n%s" % (
+                        "all", "", pagination_token
+                    ))
 
                 for room_id, group in room_groups.items():
                     group["next_batch"] = encode_base64("%s\n%s\n%s" % (