federation-api: add unstable support for MSC3843

This commit is contained in:
Matthias Ahouansou 2024-04-16 17:07:32 +01:00 committed by Kévin Commaille
parent f01f00a90a
commit becc4ac0b3
9 changed files with 76 additions and 0 deletions

View File

@ -46,6 +46,7 @@ unstable-msc2967 = []
unstable-msc3488 = []
unstable-msc3575 = []
unstable-msc3814 = []
unstable-msc3843 = []
unstable-msc3983 = []
unstable-msc4121 = []

View File

@ -195,6 +195,10 @@ pub enum ErrorKind {
current_version: Option<String>,
},
/// M_UNACTIONABLE
#[cfg(feature = "unstable-msc3843")]
Unactionable,
#[doc(hidden)]
_Custom { errcode: PrivOwnedStr, extra: Extra },
}
@ -269,6 +273,8 @@ impl AsRef<str> for ErrorKind {
Self::ConnectionFailed => "M_CONNECTION_FAILED",
Self::ConnectionTimeout => "M_CONNECTION_TIMEOUT",
Self::WrongRoomKeysVersion { .. } => "M_WRONG_ROOM_KEYS_VERSION",
#[cfg(feature = "unstable-msc3843")]
Self::Unactionable => "M_UNACTIONABLE",
Self::_Custom { errcode, .. } => &errcode.0,
}
}

View File

@ -250,6 +250,8 @@ impl<'de> Visitor<'de> for ErrorKindVisitor {
)
.map_err(de::Error::custom)?,
},
#[cfg(feature = "unstable-msc3843")]
ErrCode::Unactionable => ErrorKind::Unactionable,
ErrCode::_Custom(errcode) => ErrorKind::_Custom { errcode, extra },
})
}
@ -306,6 +308,8 @@ enum ErrCode {
ConnectionFailed,
ConnectionTimeout,
WrongRoomKeysVersion,
#[cfg(feature = "unstable-msc3843")]
Unactionable,
_Custom(PrivOwnedStr),
}

View File

@ -10,6 +10,8 @@ Improvements:
* Implement `From<SpaceHierarchyParentSummary>` for `SpaceHierarchyChildSummary`
* Add unstable support for optional `via` field on the `create_invite` endpoint request from
MSC4125 behind the `unstable-msc4125` feature.
* Add unstable support for the `report_content` endpoint from MSC3843 behind the
`unstable-msc3843` feature.
# 0.8.0

View File

@ -26,6 +26,7 @@ unstable-exhaustive-types = []
unstable-msc2448 = []
unstable-msc3618 = []
unstable-msc3723 = []
unstable-msc3843 = []
unstable-msc4125 = []
unstable-unspecified = []

View File

@ -23,6 +23,7 @@ pub mod knock;
pub mod membership;
pub mod openid;
pub mod query;
pub mod room;
pub mod space;
pub mod thirdparty;
pub mod transactions;

View File

@ -0,0 +1,4 @@
//! Server room endpoints.
#[cfg(feature = "unstable-msc3843")]
pub mod report_content;

View File

@ -0,0 +1,56 @@
//! `GET /_matrix/federation/*/rooms/{roomId}/report/{eventId}`
//!
//! Send a request to report an event originating from another server.
pub mod msc3843 {
//! `MSC3843` ([MSC])
//!
//! [MSC]: https://github.com/matrix-org/matrix-spec-proposals/pull/3843
use ruma_common::{
api::{request, response, Metadata},
metadata, OwnedEventId, OwnedRoomId,
};
const METADATA: Metadata = metadata! {
method: POST,
rate_limited: false,
authentication: ServerSignatures,
history: {
unstable => "/_matrix/federation/unstable/org.matrix.msc3843/rooms/:room_id/report/:event_id",
}
};
/// Request type for the `report_content` endpoint.
#[request]
pub struct Request {
/// The room ID that the reported event was sent in.
#[ruma_api(path)]
pub room_id: OwnedRoomId,
/// The event being reported.
#[ruma_api(path)]
pub event_id: OwnedEventId,
/// The reason that the event is being reported.
pub reason: String,
}
/// Response type for the `report_content` endpoint.
#[response]
pub struct Response {}
impl Request {
/// Creates a `Request` with the given room ID, event ID and reason.
pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId, reason: String) -> Self {
Self { room_id, event_id, reason }
}
}
impl Response {
/// Creates a new empty `Response`.
pub fn new() -> Self {
Self {}
}
}
}

View File

@ -206,6 +206,7 @@ unstable-msc3575 = ["ruma-client-api?/unstable-msc3575"]
unstable-msc3618 = ["ruma-federation-api?/unstable-msc3618"]
unstable-msc3723 = ["ruma-federation-api?/unstable-msc3723"]
unstable-msc3814 = ["ruma-client-api?/unstable-msc3814"]
unstable-msc3843 = ["ruma-client-api?/unstable-msc3843", "ruma-federation-api?/unstable-msc3843"]
unstable-msc3927 = ["ruma-events?/unstable-msc3927"]
unstable-msc3930 = ["ruma-common/unstable-msc3930"]
unstable-msc3931 = ["ruma-common/unstable-msc3931"]