client-api: Implement reasons for leaving a room

This commit is contained in:
Adam Blanchet 2021-07-07 00:08:20 +01:00 committed by Jonas Platte
parent 696c9fba4e
commit 13af2e235d
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
3 changed files with 22 additions and 1 deletions

View File

@ -8,6 +8,7 @@ Improvements:
r0::knock::knock_room r0::knock::knock_room
``` ```
* Add unstable support for room knocking. * Add unstable support for room knocking.
* Add unstable support for reasons for leaving rooms
# 0.11.0 # 0.11.0

View File

@ -17,6 +17,12 @@ ruma_api! {
/// The room to leave. /// The room to leave.
#[ruma_api(path)] #[ruma_api(path)]
pub room_id: &'a RoomId, pub room_id: &'a RoomId,
/// Optional reason to be included as the `reason` on the subsequent membership event.
#[cfg(feature = "unstable-pre-spec")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<&'a str>,
} }
#[derive(Default)] #[derive(Default)]
@ -28,7 +34,11 @@ ruma_api! {
impl<'a> Request<'a> { impl<'a> Request<'a> {
/// Creates a new `Request` with the given room id. /// Creates a new `Request` with the given room id.
pub fn new(room_id: &'a RoomId) -> Self { pub fn new(room_id: &'a RoomId) -> Self {
Self { room_id } Self {
room_id,
#[cfg(feature = "unstable-pre-spec")]
reason: None,
}
} }
} }

View File

@ -79,6 +79,12 @@ pub struct MemberEventContent {
#[serde(rename = "xyz.amorgan.blurhash")] #[serde(rename = "xyz.amorgan.blurhash")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub blurhash: Option<String>, pub blurhash: Option<String>,
/// The reason for leaving a room.
#[cfg(feature = "unstable-pre-spec")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
} }
impl MemberEventContent { impl MemberEventContent {
@ -92,6 +98,8 @@ impl MemberEventContent {
third_party_invite: None, third_party_invite: None,
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
blurhash: None, blurhash: None,
#[cfg(feature = "unstable-pre-spec")]
reason: None,
} }
} }
} }
@ -241,6 +249,8 @@ fn membership_change(
third_party_invite: None, third_party_invite: None,
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
blurhash: None, blurhash: None,
#[cfg(feature = "unstable-pre-spec")]
reason: None,
} }
}; };