1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-08-06 17:40:59 +00:00

draft: RoomEventFilter

This commit is contained in:
mikoto 2024-04-29 20:59:02 +02:00
parent 11990e7524
commit 624d1fcc9a
6 changed files with 103 additions and 2 deletions

View file

@ -109,6 +109,38 @@ pub async fn get_context_route(
let events_before: Vec<_> = events_before
.into_iter()
.map(|(_, pdu)| pdu.to_room_event())
.filter(|event| {
if let Some(types) = &body.filter.types {
types
.iter()
.find(|t| {
t == &&event
.get_field::<String>("type")
.expect("events should deserialize")
.expect("events should have a type")
})
.is_some()
} else {
true
}
})
.filter(|event| {
if !body.filter.not_types.is_empty() {
body
.filter
.not_types
.iter()
.find(|t| {
t == &&event
.get_field::<String>("type")
.expect("events should deserialize")
.expect("events should have a type")
})
.is_none()
} else {
true
}
})
.collect();
let events_after: Vec<_> = services()