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". Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
d5677b6ae7
commit
73da353e52
1 changed files with 2 additions and 5 deletions
|
@ -166,11 +166,8 @@ pub(crate) async fn search_events_route(body: Ruma<search_events::v3::Request>)
|
|||
.take(limit)
|
||||
.collect();
|
||||
|
||||
let next_batch = if results.len() < limit {
|
||||
None
|
||||
} else {
|
||||
Some(next_batch.to_string())
|
||||
};
|
||||
let more_unloaded_results = searches.iter_mut().any(|s| s.peek().is_some());
|
||||
let next_batch = more_unloaded_results.then(|| next_batch.to_string());
|
||||
|
||||
Ok(search_events::v3::Response::new(ResultCategories {
|
||||
room_events: ResultRoomEvents {
|
||||
|
|
Loading…
Add table
Reference in a new issue