refactor(perf): Push down visibility check after limit

This commit is contained in:
Jade Ellis 2025-12-18 21:31:33 +00:00
parent dd87232f1f
commit f83ddecd8c
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2

View file

@ -152,8 +152,8 @@ async fn paginate_relations_with_filter(
})
.stream()
.ready_take_while(|(count, _)| Some(*count) != to)
.wide_filter_map(|item| visibility_filter(services, sender_user, item))
.take(limit)
.wide_filter_map(|item| visibility_filter(services, sender_user, item))
.then(async |mut pdu| {
if let Err(e) = services
.rooms
@ -223,10 +223,6 @@ async fn paginate_relations_with_filter(
})
}
// TODO: Can we move the visibility filter lower down, to avoid checking events
// that won't be sent? At the moment this also results in getting events that
// appear to have no relation because intermediaries are not visible to the
// user.
async fn visibility_filter<Pdu: Event + Send + Sync>(
services: &Services,
sender_user: &UserId,