Skip to content
Snippets Groups Projects
Commit fa71dd4b authored by 🥺's avatar 🥺 :transgender_flag: Committed by 🥺
Browse files

use body.dir for relations now

parent 92dbe826
No related branches found
No related tags found
No related merge requests found
......@@ -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,
)
}
......@@ -3,7 +3,7 @@
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 @@ pub fn add_relation(&self, from: PduCount, to: PduCount) -> Result<()> {
#[allow(clippy::too_many_arguments)]
pub fn paginate_relations_with_filter(
&self, sender_user: &UserId, room_id: &RoomId, target: &EventId, filter_event_type: &Option<TimelineEventType>,
filter_rel_type: &Option<RelationType>, from: PduCount, to: Option<PduCount>, limit: usize,
filter_rel_type: &Option<RelationType>, from: PduCount, dir: Direction, to: Option<PduCount>, limit: usize,
) -> Result<get_relating_events::v1::Response> {
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 @@ pub fn paginate_relations_with_filter(
recursion_depth: None, // TODO
})
},
ruma::api::Direction::Backward => {
Direction::Backward => {
let events_before: Vec<_> = services()
.rooms
.pdu_metadata
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment