diff --git a/src/api/client_server/relations.rs b/src/api/client_server/relations.rs index 9221791c..d80374f0 100644 --- a/src/api/client_server/relations.rs +++ b/src/api/client_server/relations.rs @@ -12,8 +12,7 @@ pub async fn get_relating_events_with_rel_type_and_event_type_route( let from = match body.from.clone() { Some(from) => PduCount::try_from_string(&from)?, - None => match ruma::api::Direction::Backward { - // TODO: fix ruma so `body.dir` exists + None => match body.dir { ruma::api::Direction::Forward => PduCount::min(), ruma::api::Direction::Backward => PduCount::max(), }, @@ -41,6 +40,7 @@ pub async fn get_relating_events_with_rel_type_and_event_type_route( &Some(body.event_type.clone()), &Some(body.rel_type.clone()), from, + body.dir, to, limit, )?; @@ -61,8 +61,7 @@ pub async fn get_relating_events_with_rel_type_route( let from = match body.from.clone() { Some(from) => PduCount::try_from_string(&from)?, - None => match ruma::api::Direction::Backward { - // TODO: fix ruma so `body.dir` exists + None => match body.dir { ruma::api::Direction::Forward => PduCount::min(), ruma::api::Direction::Backward => PduCount::max(), }, @@ -90,6 +89,7 @@ pub async fn get_relating_events_with_rel_type_route( &None, &Some(body.rel_type.clone()), from, + body.dir, to, limit, )?; @@ -110,8 +110,7 @@ pub async fn get_relating_events_route( let from = match body.from.clone() { Some(from) => PduCount::try_from_string(&from)?, - None => match ruma::api::Direction::Backward { - // TODO: fix ruma so `body.dir` exists + None => match body.dir { ruma::api::Direction::Forward => PduCount::min(), ruma::api::Direction::Backward => PduCount::max(), }, @@ -132,5 +131,15 @@ pub async fn get_relating_events_route( services() .rooms .pdu_metadata - .paginate_relations_with_filter(sender_user, &body.room_id, &body.event_id, &None, &None, from, to, limit) + .paginate_relations_with_filter( + sender_user, + &body.room_id, + &body.event_id, + &None, + &None, + from, + body.dir, + to, + limit, + ) } diff --git a/src/service/rooms/pdu_metadata/mod.rs b/src/service/rooms/pdu_metadata/mod.rs index f6eab28a..9387c343 100644 --- a/src/service/rooms/pdu_metadata/mod.rs +++ b/src/service/rooms/pdu_metadata/mod.rs @@ -3,7 +3,7 @@ use std::sync::Arc; pub use data::Data; use ruma::{ - api::client::relations::get_relating_events, + api::{client::relations::get_relating_events, Direction}, events::{relation::RelationType, TimelineEventType}, EventId, RoomId, UserId, }; @@ -42,13 +42,12 @@ impl Service { #[allow(clippy::too_many_arguments)] pub fn paginate_relations_with_filter( &self, sender_user: &UserId, room_id: &RoomId, target: &EventId, filter_event_type: &Option, - filter_rel_type: &Option, from: PduCount, to: Option, limit: usize, + filter_rel_type: &Option, from: PduCount, dir: Direction, to: Option, limit: usize, ) -> Result { let next_token; - //TODO: Fix ruma: match body.dir { - match ruma::api::Direction::Backward { - ruma::api::Direction::Forward => { + match dir { + Direction::Forward => { let events_after: Vec<_> = services() .rooms .pdu_metadata @@ -94,7 +93,7 @@ impl Service { recursion_depth: None, // TODO }) }, - ruma::api::Direction::Backward => { + Direction::Backward => { let events_before: Vec<_> = services() .rooms .pdu_metadata