federation-api: Replace Raw<Pdu> with Box<RawJsonValue>

This commit is contained in:
Jonas Platte 2021-09-15 20:27:57 +02:00
parent da14fdaf17
commit 36bc8bf73a
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
16 changed files with 65 additions and 62 deletions

View File

@ -1,5 +1,9 @@
# [unreleased]
Breaking changes:
* Replace `Raw<Pdu>` with `Box<RawJsonValue>`
# 0.3.1
Bug fixes:

View File

@ -1,9 +1,8 @@
//! [GET /_matrix/federation/v1/event_auth/{roomId}/{eventId}](https://matrix.org/docs/spec/server_server/r0.1.4#get-matrix-federation-v1-event-auth-roomid-eventid)
use ruma_api::ruma_api;
use ruma_events::pdu::Pdu;
use ruma_identifiers::{EventId, RoomId};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {
metadata: {
@ -28,7 +27,7 @@ ruma_api! {
response: {
/// The full set of authorization events that make up the state of the room,
/// and their authorization events, recursively.
pub auth_chain: Vec<Raw<Pdu>>,
pub auth_chain: Vec<Box<RawJsonValue>>,
}
}
@ -41,7 +40,7 @@ impl<'a> Request<'a> {
impl Response {
/// Creates a new `Response` with the given auth chain.
pub fn new(auth_chain: Vec<Raw<Pdu>>) -> Self {
pub fn new(auth_chain: Vec<Box<RawJsonValue>>) -> Self {
Self { auth_chain }
}
}

View File

@ -3,9 +3,9 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::pdu::Pdu;
use ruma_identifiers::{EventId, RoomId, ServerNameBox};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {
metadata: {
@ -39,7 +39,7 @@ ruma_api! {
pub origin_server_ts: MilliSecondsSinceUnixEpoch,
/// List of persistent updates to rooms.
pub pdus: Vec<Raw<Pdu>>,
pub pdus: Vec<Box<RawJsonValue>>,
}
}
@ -61,7 +61,7 @@ impl Response {
pub fn new(
origin: ServerNameBox,
origin_server_ts: MilliSecondsSinceUnixEpoch,
pdus: Vec<Raw<Pdu>>,
pdus: Vec<Box<RawJsonValue>>,
) -> Self {
Self { origin, origin_server_ts, pdus }
}

View File

@ -2,9 +2,9 @@
use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::pdu::Pdu;
use ruma_identifiers::{EventId, ServerNameBox};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {
metadata: {
@ -31,7 +31,7 @@ ruma_api! {
/// The event.
#[serde(rename = "pdus", with = "ruma_serde::single_element_seq")]
pub pdu: Raw<Pdu>,
pub pdu: Box<RawJsonValue>,
}
}
@ -47,7 +47,7 @@ impl Response {
pub fn new(
origin: ServerNameBox,
origin_server_ts: MilliSecondsSinceUnixEpoch,
pdu: Raw<Pdu>,
pdu: Box<RawJsonValue>,
) -> Self {
Self { origin, origin_server_ts, pdu }
}

View File

@ -2,9 +2,9 @@
use js_int::{uint, UInt};
use ruma_api::ruma_api;
use ruma_events::pdu::Pdu;
use ruma_identifiers::{EventId, RoomId};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {
metadata: {
@ -39,7 +39,7 @@ ruma_api! {
#[derive(Default)]
response: {
/// The missing PDUs.
pub events: Vec<Raw<Pdu>>,
pub events: Vec<Box<RawJsonValue>>,
}
}
@ -62,7 +62,7 @@ impl<'a> Request<'a> {
impl Response {
/// Creates a new `Response` with the given events.
pub fn new(events: Vec<Raw<Pdu>>) -> Self {
pub fn new(events: Vec<Box<RawJsonValue>>) -> Self {
Self { events }
}
}

View File

@ -1,9 +1,9 @@
//! [GET /_matrix/federation/v1/state/{roomId}](https://matrix.org/docs/spec/server_server/r0.1.4#get-matrix-federation-v1-state-roomid)
use ruma_api::ruma_api;
use ruma_events::pdu::Pdu;
use ruma_identifiers::{EventId, RoomId};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {
metadata: {
@ -28,10 +28,10 @@ ruma_api! {
response: {
/// The full set of authorization events that make up the state of the
/// room, and their authorization events, recursively.
pub auth_chain: Vec<Raw<Pdu>>,
pub auth_chain: Vec<Box<RawJsonValue>>,
/// The fully resolved state of the room at the given event.
pub pdus: Vec<Raw<Pdu>>,
pub pdus: Vec<Box<RawJsonValue>>,
}
}
@ -44,7 +44,7 @@ impl<'a> Request<'a> {
impl Response {
/// Creates a new `Response` with the given auth chain and room state.
pub fn new(auth_chain: Vec<Raw<Pdu>>, pdus: Vec<Raw<Pdu>>) -> Self {
pub fn new(auth_chain: Vec<Box<RawJsonValue>>, pdus: Vec<Box<RawJsonValue>>) -> Self {
Self { auth_chain, pdus }
}
}

View File

@ -1,9 +1,8 @@
//! [GET /_matrix/federation/v1/make_knock/{roomId}/{userId}](https://spec.matrix.org/unstable/server-server-api/#get_matrixfederationv1make_knockroomiduserid)
use ruma_api::ruma_api;
use ruma_events::pdu::Pdu;
use ruma_identifiers::{RoomId, RoomVersionId, UserId};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {
metadata: {
@ -38,7 +37,7 @@ ruma_api! {
/// An unsigned template event.
///
/// May differ between room versions.
pub event: Raw<Pdu>,
pub event: Box<RawJsonValue>,
}
}
@ -51,7 +50,7 @@ impl<'a> Request<'a> {
impl Response {
/// Creates a new `Response` with the given room version ID and event.
pub fn new(room_version: RoomVersionId, event: Raw<Pdu>) -> Self {
pub fn new(room_version: RoomVersionId, event: Box<RawJsonValue>) -> Self {
Self { room_version, event }
}
}

View File

@ -2,10 +2,11 @@
use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{pdu::Pdu, room::member::MemberEventContent, AnyStrippedStateEvent, EventType};
use ruma_events::{room::member::MemberEventContent, AnyStrippedStateEvent, EventType};
use ruma_identifiers::{EventId, RoomId, ServerName, UserId};
use ruma_serde::Raw;
use serde::{Deserialize, Serialize};
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {
metadata: {
@ -54,7 +55,7 @@ ruma_api! {
/// The signed invite event.
#[ruma_api(body)]
#[serde(with = "crate::serde::v1_pdu")]
pub event: Raw<Pdu>,
pub event: Box<RawJsonValue>,
}
}
@ -129,7 +130,7 @@ impl<'a> From<RequestInit<'a>> for Request<'a> {
impl Response {
/// Creates a new `Response` with the given invite event.
pub fn new(event: Raw<Pdu>) -> Self {
pub fn new(event: Box<RawJsonValue>) -> Self {
Self { event }
}
}

View File

@ -1,9 +1,10 @@
//! [PUT /_matrix/federation/v2/invite/{roomId}/{eventId}](https://matrix.org/docs/spec/server_server/r0.1.4#put-matrix-federation-v2-invite-roomid-eventid)
use ruma_api::ruma_api;
use ruma_events::{pdu::Pdu, AnyStrippedStateEvent};
use ruma_events::AnyStrippedStateEvent;
use ruma_identifiers::{EventId, RoomId, RoomVersionId};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {
metadata: {
@ -28,7 +29,7 @@ ruma_api! {
pub room_version: RoomVersionId,
/// The invite event which needs to be signed.
pub event: Raw<Pdu>,
pub event: Box<RawJsonValue>,
/// An optional list of simplified events to help the receiver of the invite identify the room.
pub invite_room_state: Vec<Raw<AnyStrippedStateEvent>>,
@ -36,7 +37,7 @@ ruma_api! {
response: {
/// The signed invite event.
pub event: Raw<Pdu>,
pub event: Box<RawJsonValue>,
}
}
@ -47,7 +48,7 @@ impl Request {
room_id: RoomId,
event_id: EventId,
room_version: RoomVersionId,
event: Raw<Pdu>,
event: Box<RawJsonValue>,
invite_room_state: Vec<Raw<AnyStrippedStateEvent>>,
) -> Self {
Self { room_id, event_id, room_version, event, invite_room_state }
@ -56,7 +57,7 @@ impl Request {
impl Response {
/// Creates a new `Response` with the given invite event.
pub fn new(event: Raw<Pdu>) -> Self {
pub fn new(event: Box<RawJsonValue>) -> Self {
Self { event }
}
}

View File

@ -3,9 +3,8 @@
pub mod v1;
pub mod v2;
use ruma_events::pdu::Pdu;
use ruma_serde::Raw;
use serde::{Deserialize, Serialize};
use serde_json::value::RawValue as RawJsonValue;
/// Full state of the room.
#[derive(Clone, Debug, Deserialize, Serialize)]
@ -18,10 +17,10 @@ pub struct RoomState {
/// The full set of authorization events that make up the state of the room,
/// and their authorization events, recursively.
pub auth_chain: Vec<Raw<Pdu>>,
pub auth_chain: Vec<Box<RawJsonValue>>,
/// The room state.
pub state: Vec<Raw<Pdu>>,
pub state: Vec<Box<RawJsonValue>>,
}
#[cfg(feature = "unstable-pre-spec")]

View File

@ -1,9 +1,9 @@
//! [PUT /_matrix/federation/v1/send_join/{roomId}/{eventId}](https://matrix.org/docs/spec/server_server/r0.1.3#put-matrix-federation-v1-send-join-roomid-eventid)
use ruma_api::ruma_api;
use ruma_events::pdu::Pdu;
use ruma_identifiers::{EventId, RoomId};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
use super::RoomState;
@ -30,7 +30,7 @@ ruma_api! {
/// The PDU.
#[ruma_api(body)]
pub pdu: Raw<Pdu>,
pub pdu: Box<RawJsonValue>,
}
response: {
@ -42,8 +42,8 @@ ruma_api! {
}
impl<'a> Request<'a> {
/// Creates a new `Request` from the given room ID, event ID and `Pdu`.
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu: Raw<Pdu>) -> Self {
/// Creates a new `Request` from the given room ID, event ID and PDU.
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu: Box<RawJsonValue>) -> Self {
Self { room_id, event_id, pdu }
}
}

View File

@ -1,9 +1,9 @@
//! [PUT /_matrix/federation/v2/send_join/{roomId}/{eventId}](https://matrix.org/docs/spec/server_server/r0.1.4#put-matrix-federation-v2-send-join-roomid-eventid)
use ruma_api::ruma_api;
use ruma_events::pdu::Pdu;
use ruma_identifiers::{EventId, RoomId};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
use super::RoomState;
@ -30,7 +30,7 @@ ruma_api! {
/// The PDU.
#[ruma_api(body)]
pub pdu: Raw<Pdu>,
pub pdu: Box<RawJsonValue>,
}
response: {
@ -41,8 +41,8 @@ ruma_api! {
}
impl<'a> Request<'a> {
/// Creates a new `Request` from the given room ID, event ID and `Pdu`.
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu: Raw<Pdu>) -> Self {
/// Creates a new `Request` from the given room ID, event ID and PDU.
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu: Box<RawJsonValue>) -> Self {
Self { room_id, event_id, pdu }
}
}

View File

@ -1,9 +1,9 @@
//! [GET /_matrix/federation/v1/make_join/{roomId}/{userId}](https://matrix.org/docs/spec/server_server/r0.1.3#get-matrix-federation-v1-make-join-roomid-userid)
use ruma_api::ruma_api;
use ruma_events::pdu::Pdu;
use ruma_identifiers::{RoomId, RoomVersionId, UserId};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {
metadata: {
@ -38,7 +38,7 @@ ruma_api! {
pub room_version: Option<RoomVersionId>,
/// An unsigned template event.
pub event: Raw<Pdu>,
pub event: Box<RawJsonValue>,
}
}
@ -59,7 +59,7 @@ impl<'a> Request<'a> {
impl Response {
/// Creates a new `Response` with the given template event.
pub fn new(event: Raw<Pdu>) -> Self {
pub fn new(event: Box<RawJsonValue>) -> Self {
Self { room_version: None, event }
}
}

View File

@ -1,9 +1,9 @@
//! [PUT /_matrix/federation/v2/send_leave/{roomId}/{eventId}](https://matrix.org/docs/spec/server_server/r0.1.4#put-matrix-federation-v2-send-leave-roomid-eventid)
use ruma_api::ruma_api;
use ruma_events::pdu::Pdu;
use ruma_identifiers::{EventId, RoomId};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {
metadata: {
@ -28,7 +28,7 @@ ruma_api! {
/// The PDU.
#[ruma_api(body)]
pub pdu: Raw<Pdu>,
pub pdu: Box<RawJsonValue>,
}
#[derive(Default)]
@ -36,8 +36,8 @@ ruma_api! {
}
impl<'a> Request<'a> {
/// Creates a new `Request` from the given room ID, event ID and `Pdu`.
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu: Raw<Pdu>) -> Self {
/// Creates a new `Request` from the given room ID, event ID and PDU.
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu: Box<RawJsonValue>) -> Self {
Self { room_id, event_id, pdu }
}
}

View File

@ -1,9 +1,9 @@
//! [GET /_matrix/federation/v1/make_leave/{roomId}/{userId}](https://matrix.org/docs/spec/server_server/r0.1.4#get-matrix-federation-v1-make-leave-roomid-userid)
use ruma_api::ruma_api;
use ruma_events::pdu::Pdu;
use ruma_identifiers::{RoomId, RoomVersionId, UserId};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
ruma_api! {
metadata: {
@ -32,7 +32,7 @@ ruma_api! {
/// An unsigned template event. Note that events have a different format depending on the
/// room version - check the room version specification for precise event formats.
pub event: Raw<Pdu>,
pub event: Box<RawJsonValue>,
}
}
@ -49,7 +49,7 @@ impl Response {
/// Creates a new `Response` with:
/// * the version of the room where the server is trying to leave.
/// * an unsigned template event.
pub fn new(room_version: Option<RoomVersionId>, event: Raw<Pdu>) -> Self {
pub fn new(room_version: Option<RoomVersionId>, event: Box<RawJsonValue>) -> Self {
Self { room_version, event }
}
}

View File

@ -4,9 +4,9 @@ use std::collections::BTreeMap;
use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::pdu::Pdu;
use ruma_identifiers::{EventId, ServerName};
use ruma_serde::Raw;
use serde_json::value::RawValue as RawJsonValue;
use crate::transactions::edu::Edu;
@ -36,7 +36,7 @@ ruma_api! {
///
/// Must not be more than 50 items.
#[cfg_attr(feature = "unstable-pre-spec", serde(default, skip_serializing_if = "<[_]>::is_empty"))]
pub pdus: &'a [Raw<Pdu>],
pub pdus: &'a [Box<RawJsonValue>],
/// List of ephemeral messages.
///