fix missing next_batch for search

The previous code would fail to return next_batch if any of the events
in the window were not visible to the user. It would also return an
unnecessary next_batch when no more results are available if the total
number of results is exactly `skip + limit`.

This bug will become much more severe with a full filtering
implementation, because we will be more likely to trigger it by
filtering out events in a search call. Currently, it is only possible to
trigger with rooms that have history visibility set to "invited" or
"joined".
This commit is contained in:
Benjamin Lee 2024-06-04 00:38:53 -07:00
parent c1ec1111ae
commit 0cdf03288a
No known key found for this signature in database
GPG key ID: FB9624E2885D55A4

View file

@ -130,11 +130,8 @@ pub(crate) async fn search_events_route(
.take(limit) .take(limit)
.collect(); .collect();
let next_batch = if results.len() < limit { let more_unloaded_results = searches.iter_mut().any(|s| s.peek().is_some());
None let next_batch = more_unloaded_results.then(|| (skip + limit).to_string());
} else {
Some((skip + limit).to_string())
};
Ok(Ra(search_events::v3::Response::new(ResultCategories { Ok(Ra(search_events::v3::Response::new(ResultCategories {
room_events: ResultRoomEvents { room_events: ResultRoomEvents {