Consolidate concurrent event filters in messages iteration.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -122,8 +122,7 @@ pub(crate) async fn get_message_events_route(
|
|||||||
let events: Vec<_> = it
|
let events: Vec<_> = it
|
||||||
.ready_take_while(|(count, _)| Some(*count) != to)
|
.ready_take_while(|(count, _)| Some(*count) != to)
|
||||||
.ready_filter_map(|item| event_filter(item, filter))
|
.ready_filter_map(|item| event_filter(item, filter))
|
||||||
.wide_filter_map(|item| ignored_filter(&services, item, sender_user))
|
.wide_filter_map(|item| event_filters(&services, sender_user, item))
|
||||||
.wide_filter_map(|item| visibility_filter(&services, item, sender_user))
|
|
||||||
.take(limit)
|
.take(limit)
|
||||||
.collect()
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
@@ -228,6 +227,17 @@ async fn get_member_event(
|
|||||||
.ok()
|
.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn event_filters(
|
||||||
|
services: &Services,
|
||||||
|
user_id: &UserId,
|
||||||
|
item: PdusIterItem,
|
||||||
|
) -> Option<PdusIterItem> {
|
||||||
|
let item = ignored_filter(services, item, user_id).await?;
|
||||||
|
let item = visibility_filter(services, item, user_id).await?;
|
||||||
|
|
||||||
|
Some(item)
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) async fn ignored_filter(
|
pub(crate) async fn ignored_filter(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
@@ -238,7 +248,7 @@ pub(crate) async fn ignored_filter(
|
|||||||
|
|
||||||
is_ignored_pdu(services, pdu, user_id)
|
is_ignored_pdu(services, pdu, user_id)
|
||||||
.await
|
.await
|
||||||
.eq(&false)
|
.is_false()
|
||||||
.then_some(item)
|
.then_some(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user