feat: Filter ignored PDUs in relations

This commit is contained in:
timedout 2026-01-22 14:08:54 +00:00 committed by Jade Ellis
parent f1ab27d344
commit a9ebdf58e2
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2
2 changed files with 17 additions and 6 deletions

View file

@ -1,6 +1,6 @@
use axum::extract::State; use axum::extract::State;
use conduwuit::{ use conduwuit::{
Err, Error, Event, Result, at, debug_warn, err, ref_at, Err, Event, Result, at, debug_warn, err, ref_at,
utils::{ utils::{
IterStream, IterStream,
future::TryExtExt, future::TryExtExt,
@ -12,11 +12,7 @@ use futures::{
FutureExt, StreamExt, TryFutureExt, TryStreamExt, FutureExt, StreamExt, TryFutureExt, TryStreamExt,
future::{OptionFuture, join, join3, try_join3}, future::{OptionFuture, join, join3, try_join3},
}; };
use ruma::{ use ruma::{OwnedEventId, UserId, api::client::context::get_context, events::StateEventType};
OwnedEventId, UserId,
api::client::{context::get_context, error::ErrorKind},
events::StateEventType,
};
use crate::{ use crate::{
Ruma, Ruma,

View file

@ -167,6 +167,7 @@ async fn paginate_relations_with_filter(
.ready_take_while(|(count, _)| Some(*count) != to) .ready_take_while(|(count, _)| Some(*count) != to)
.take(limit) .take(limit)
.wide_filter_map(|item| visibility_filter(services, sender_user, item)) .wide_filter_map(|item| visibility_filter(services, sender_user, item))
.wide_filter_map(|item| ignored_filter(services, item, sender_user))
.then(async |mut pdu| { .then(async |mut pdu| {
if let Err(e) = services if let Err(e) = services
.rooms .rooms
@ -222,3 +223,17 @@ async fn visibility_filter<Pdu: Event + Send + Sync>(
.await .await
.then_some(item) .then_some(item)
} }
async fn ignored_filter<Pdu: Event + Send + Sync>(
services: &Services,
item: (PduCount, Pdu),
sender_user: &UserId,
) -> Option<(PduCount, Pdu)> {
let (_, pdu) = &item;
if is_ignored_pdu(services, pdu, sender_user).await.ok()? {
None
} else {
Some(item)
}
}