From b168c38d831231a60773d8a6a7c67782ec09fd17 Mon Sep 17 00:00:00 2001 From: Guillem Nieto Date: Wed, 18 Nov 2020 18:23:04 +0100 Subject: [PATCH] Use `Pdu` on `create_join_event` endpoints Sending requests to this endpoints to Synapse/Dendrite homeservers leads to some deserialization errors. After claryfing it (https://github.com/matrix-org/matrix-doc/issues/2856), `room_id` and `event_id` fields are expected to appear on request's body and also on path params. It seems that there's some initiative, in any case, to remove the parameters from path: https://github.com/matrix-org/matrix-doc/issues/2330 --- ruma-federation-api/CHANGELOG.md | 1 + .../src/membership/create_join_event/v1.rs | 11 +++++------ .../src/membership/create_join_event/v2.rs | 11 +++++------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/ruma-federation-api/CHANGELOG.md b/ruma-federation-api/CHANGELOG.md index 9c14ffc2..a955c286 100644 --- a/ruma-federation-api/CHANGELOG.md +++ b/ruma-federation-api/CHANGELOG.md @@ -5,6 +5,7 @@ Breaking Changes: * Replace `directory::get_public_rooms::v1::{PublicRoomsChunk, RoomNetwork}` with types from `ruma_common::directory` * Wrap `PduStub`s in `membership::create_join_event` in `Raw` +* Use `Pdu` instead of `PduStub` in `membership::create_join_event` endpoints Improvements: diff --git a/ruma-federation-api/src/membership/create_join_event/v1.rs b/ruma-federation-api/src/membership/create_join_event/v1.rs index 14b720b2..db5df191 100644 --- a/ruma-federation-api/src/membership/create_join_event/v1.rs +++ b/ruma-federation-api/src/membership/create_join_event/v1.rs @@ -2,7 +2,7 @@ use ruma_api::ruma_api; use ruma_common::Raw; -use ruma_events::pdu::PduStub; +use ruma_events::pdu::Pdu; use ruma_identifiers::{EventId, RoomId}; use super::RoomState; @@ -26,9 +26,9 @@ ruma_api! { #[ruma_api(path)] pub event_id: &'a EventId, - /// PDU type without event and room IDs. + /// PDU type #[ruma_api(body)] - pub pdu_stub: Raw, + pub pdu_stub: Raw, } response: { @@ -39,10 +39,9 @@ ruma_api! { } } -// FIXME: Construct from Pdu, same for similar endpoints impl<'a> Request<'a> { - /// Creates a `Request` from the given room ID, event ID and `PduStub`. - pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu_stub: Raw) -> Self { + /// Creates a `Request` from the given room ID, event ID and `Pdu`. + pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu_stub: Raw) -> Self { Self { room_id, event_id, pdu_stub } } } diff --git a/ruma-federation-api/src/membership/create_join_event/v2.rs b/ruma-federation-api/src/membership/create_join_event/v2.rs index 94325b9c..21918ee6 100644 --- a/ruma-federation-api/src/membership/create_join_event/v2.rs +++ b/ruma-federation-api/src/membership/create_join_event/v2.rs @@ -2,7 +2,7 @@ use ruma_api::ruma_api; use ruma_common::Raw; -use ruma_events::pdu::PduStub; +use ruma_events::pdu::Pdu; use ruma_identifiers::{EventId, RoomId}; use super::RoomState; @@ -26,9 +26,9 @@ ruma_api! { #[ruma_api(path)] pub event_id: &'a EventId, - /// PDU type without event and room IDs. + /// PDU type #[ruma_api(body)] - pub pdu_stub: Raw, + pub pdu_stub: Raw, } response: { @@ -38,10 +38,9 @@ ruma_api! { } } -// FIXME: Construct from Pdu, same for similar endpoints impl<'a> Request<'a> { - /// Creates a `Request` from the given room ID, event ID and `PduStub`. - pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu_stub: Raw) -> Self { + /// Creates a `Request` from the given room ID, event ID and `Pdu`. + pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu_stub: Raw) -> Self { Self { room_id, event_id, pdu_stub } } }