add MSC2815 support, query param and error codes
https://github.com/matrix-org/matrix-spec-proposals/pull/2815 Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
1c4eeb4c41
commit
9f6c48eea2
@ -33,6 +33,19 @@ mod kind_serde;
|
|||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum ErrorKind {
|
pub enum ErrorKind {
|
||||||
|
/// M_UNREDACTED_CONTENT_DELETED and FI.MAU.MSC2815_UNREDACTED_CONTENT_DELETED
|
||||||
|
///
|
||||||
|
/// as per MSC2815
|
||||||
|
UnredactedContentDeleted {
|
||||||
|
/// fi.mau.msc2815.content_keep_ms
|
||||||
|
content_keep_ms: Option<Duration>,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// M_UNREDACTED_CONTENT_NOT_RECEIVED and FI.MAU.MSC2815_UNREDACTED_CONTENT_NOT_RECEIVED
|
||||||
|
///
|
||||||
|
/// as per MSC2815
|
||||||
|
UnredactedContentNotReceived,
|
||||||
|
|
||||||
/// M_FORBIDDEN
|
/// M_FORBIDDEN
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
Forbidden {
|
Forbidden {
|
||||||
@ -238,6 +251,10 @@ pub struct Extra(BTreeMap<String, JsonValue>);
|
|||||||
impl AsRef<str> for ErrorKind {
|
impl AsRef<str> for ErrorKind {
|
||||||
fn as_ref(&self) -> &str {
|
fn as_ref(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
|
// TODO: replace with M_UNREDACTED_CONTENT_DELETED when stabilised
|
||||||
|
Self::UnredactedContentDeleted { .. } => "FI.MAU.MSC2815_UNREDACTED_CONTENT_DELETED",
|
||||||
|
// TODO: replace with M_UNREDACTED_CONTENT_NOT_RECEIVED when stabilised
|
||||||
|
Self::UnredactedContentNotReceived => "FI.MAU.MSC2815_UNREDACTED_CONTENT_NOT_RECEIVED",
|
||||||
Self::Forbidden { .. } => "M_FORBIDDEN",
|
Self::Forbidden { .. } => "M_FORBIDDEN",
|
||||||
Self::UnknownToken { .. } => "M_UNKNOWN_TOKEN",
|
Self::UnknownToken { .. } => "M_UNKNOWN_TOKEN",
|
||||||
Self::MissingToken => "M_MISSING_TOKEN",
|
Self::MissingToken => "M_MISSING_TOKEN",
|
||||||
|
@ -35,6 +35,17 @@ pub mod v3 {
|
|||||||
/// The ID of the event.
|
/// The ID of the event.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_id: OwnedEventId,
|
pub event_id: OwnedEventId,
|
||||||
|
|
||||||
|
/// Query parameter to tell the server if it should return the redacted content of the
|
||||||
|
/// requested event
|
||||||
|
///
|
||||||
|
/// as per MSC2815: https://github.com/matrix-org/matrix-spec-proposals/pull/2815
|
||||||
|
#[ruma_api(query)]
|
||||||
|
#[serde(
|
||||||
|
skip_serializing_if = "Option::is_none",
|
||||||
|
alias = "fi.mau.msc2815.include_unredacted_content"
|
||||||
|
)]
|
||||||
|
pub include_unredacted_content: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_room_event` endpoint.
|
/// Response type for the `get_room_event` endpoint.
|
||||||
@ -47,8 +58,12 @@ pub mod v3 {
|
|||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given room ID and event ID.
|
/// Creates a new `Request` with the given room ID and event ID.
|
||||||
pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId) -> Self {
|
pub fn new(
|
||||||
Self { room_id, event_id }
|
room_id: OwnedRoomId,
|
||||||
|
event_id: OwnedEventId,
|
||||||
|
include_unredacted_content: Option<bool>,
|
||||||
|
) -> Self {
|
||||||
|
Self { room_id, event_id, include_unredacted_content }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,17 @@ pub mod v1 {
|
|||||||
/// The event ID to get.
|
/// The event ID to get.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_id: OwnedEventId,
|
pub event_id: OwnedEventId,
|
||||||
|
|
||||||
|
/// Query parameter to tell the server if it should return the redacted content of the
|
||||||
|
/// requested event
|
||||||
|
///
|
||||||
|
/// as per MSC2815: https://github.com/matrix-org/matrix-spec-proposals/pull/2815
|
||||||
|
#[ruma_api(query)]
|
||||||
|
#[serde(
|
||||||
|
skip_serializing_if = "Option::is_none",
|
||||||
|
alias = "fi.mau.msc2815.include_unredacted_content"
|
||||||
|
)]
|
||||||
|
pub include_unredacted_content: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response type for the `get_event` endpoint.
|
/// Response type for the `get_event` endpoint.
|
||||||
@ -46,8 +57,8 @@ pub mod v1 {
|
|||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given event id.
|
/// Creates a new `Request` with the given event id.
|
||||||
pub fn new(event_id: OwnedEventId) -> Self {
|
pub fn new(event_id: OwnedEventId, include_unredacted_content: Option<bool>) -> Self {
|
||||||
Self { event_id }
|
Self { event_id, include_unredacted_content }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user