summary refs log tree commit diff
path: root/synapse/handlers/search.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-12-02 10:40:22 +0000
committerMark Haines <mark.haines@matrix.org>2015-12-02 10:40:22 +0000
commit2a0ec3b89d6b97e8a91ef5320d5e6675acacffdd (patch)
treebc022d01b40c2fdc701d4e1183931217cb6dfd6f /synapse/handlers/search.py
parentOnly fire user_joined_room if the membership has changed (diff)
parentMerge pull request #409 from MadsRC/develop (diff)
downloadsynapse-2a0ec3b89d6b97e8a91ef5320d5e6675acacffdd.tar.xz
Merge branch 'develop' into markjh/edu_frequency
Conflicts:
	synapse/handlers/federation.py
	synapse/handlers/room.py
Diffstat (limited to 'synapse/handlers/search.py')
-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" % (