From b695dee7872aca5bd54096f4c47c4bb6f25b3154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Fri, 30 Sep 2022 21:49:48 +0200 Subject: [PATCH] client-api: Add support for dir parameter to /relations According to MSC3715 --- crates/ruma-client-api/CHANGELOG.md | 1 + .../src/relations/get_relating_events.rs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/ruma-client-api/CHANGELOG.md b/crates/ruma-client-api/CHANGELOG.md index 50241b44..30d396c1 100644 --- a/crates/ruma-client-api/CHANGELOG.md +++ b/crates/ruma-client-api/CHANGELOG.md @@ -15,6 +15,7 @@ Improvements: * The fields added to `RoomEventFilter` were removed by MSC3856 * Add support for the threads list API (MSC3856 / Matrix 1.4) * Stabilize support for private read receipts +* Add support for the pagination direction parameter to `/relations` (MSC3715 / Matrix 1.4) # 0.15.1 diff --git a/crates/ruma-client-api/src/relations/get_relating_events.rs b/crates/ruma-client-api/src/relations/get_relating_events.rs index ad6ffc0d..52b6495d 100644 --- a/crates/ruma-client-api/src/relations/get_relating_events.rs +++ b/crates/ruma-client-api/src/relations/get_relating_events.rs @@ -10,6 +10,8 @@ pub mod v1 { use js_int::UInt; use ruma_common::{api::ruma_api, events::AnyMessageLikeEvent, serde::Raw, EventId, RoomId}; + use crate::Direction; + ruma_api! { metadata: { description: "Get the child events for a given parent event.", @@ -35,8 +37,8 @@ pub mod v1 { /// /// If `None`, results start at the most recent topological event known to the server. /// - /// Can be a `next_batch` token from a previous call, or a returned `start` token from - /// `/messages` or a `next_batch` token from `/sync`. + /// Can be a `next_batch` or `prev_batch` token from a previous call, or a returned + /// `start` token from `/messages` or a `next_batch` token from `/sync`. /// /// Note that when paginating the `from` token should be "after" the `to` token in /// terms of topological ordering, because it is only possible to paginate "backwards" @@ -45,6 +47,13 @@ pub mod v1 { #[ruma_api(query)] pub from: Option<&'a str>, + /// The direction to return events from. + /// + /// Defaults to [`Direction::Backward`]. + #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] + #[ruma_api(query)] + pub dir: Direction, + /// The pagination token to stop returning results at. /// /// If `None`, results continue up to `limit` or until there are no more events. @@ -96,7 +105,7 @@ pub mod v1 { impl<'a> Request<'a> { /// Creates a new `Request` with the given room ID and parent event ID. pub fn new(room_id: &'a RoomId, event_id: &'a EventId) -> Self { - Self { room_id, event_id, from: None, to: None, limit: None } + Self { room_id, event_id, dir: Direction::default(), from: None, to: None, limit: None } } }