fix dropped events in search

The previous code would drop some events entirely if any events between
`skip` and `skip + limit` were not visible to the user. This would cause
the set of events skipped by the `skip(skip)` method to extend past
`skip` in the raw result set, because `skip(skip)` was being called
*after* filtering out invisible events.

This bug will become much more severe with a full filtering
implementation, because it will be more likely for events to be filtered
out. 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:
Benjamin Lee 2024-06-12 00:17:03 -04:00 committed by June 🍓🦴
parent 73da353e52
commit 81cd677b4e

View file

@ -133,6 +133,7 @@ pub(crate) async fn search_events_route(body: Ruma<search_events::v3::Request>)
let results: Vec<_> = results
.iter()
.skip(skip)
.filter_map(|result| {
services()
.rooms
@ -162,7 +163,6 @@ pub(crate) async fn search_events_route(body: Ruma<search_events::v3::Request>)
})
})
.filter_map(Result::ok)
.skip(skip)
.take(limit)
.collect();