Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Search: Don't disregard grouping info in pagination tokens #406

Merged
merged 1 commit into from
Dec 2, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions synapse/handlers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,18 @@ def search(self, user, content, batch=None):
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" % (
Expand Down