Skip to content

Commit

Permalink
Use Pdu on create_join_event endpoints
Browse files Browse the repository at this point in the history
Sending requests to this endpoints to Synapse/Dendrite homeservers leads
to some deserialization errors.

After claryfing it
(matrix-org/matrix-spec-proposals#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
  • Loading branch information
gnieto authored and jplatte committed Nov 18, 2020
1 parent 9a4206b commit b168c38
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions ruma-federation-api/CHANGELOG.md
Expand Up @@ -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:

Expand Down
11 changes: 5 additions & 6 deletions ruma-federation-api/src/membership/create_join_event/v1.rs
Expand Up @@ -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;
Expand All @@ -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<PduStub>,
pub pdu_stub: Raw<Pdu>,
}

response: {
Expand All @@ -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<PduStub>) -> 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<Pdu>) -> Self {
Self { room_id, event_id, pdu_stub }
}
}
Expand Down
11 changes: 5 additions & 6 deletions ruma-federation-api/src/membership/create_join_event/v2.rs
Expand Up @@ -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;
Expand All @@ -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<PduStub>,
pub pdu_stub: Raw<Pdu>,
}

response: {
Expand All @@ -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<PduStub>) -> 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<Pdu>) -> Self {
Self { room_id, event_id, pdu_stub }
}
}
Expand Down

0 comments on commit b168c38

Please sign in to comment.