diff --git a/crates/ruma-client-api/CHANGELOG.md b/crates/ruma-client-api/CHANGELOG.md index 1323f5be..6c45faee 100644 --- a/crates/ruma-client-api/CHANGELOG.md +++ b/crates/ruma-client-api/CHANGELOG.md @@ -8,6 +8,7 @@ Improvements: r0::knock::knock_room ``` * Add unstable support for room knocking. +* Add unstable support for reasons for leaving rooms # 0.11.0 diff --git a/crates/ruma-client-api/src/r0/membership/leave_room.rs b/crates/ruma-client-api/src/r0/membership/leave_room.rs index d900df20..f787f2e9 100644 --- a/crates/ruma-client-api/src/r0/membership/leave_room.rs +++ b/crates/ruma-client-api/src/r0/membership/leave_room.rs @@ -17,6 +17,12 @@ ruma_api! { /// The room to leave. #[ruma_api(path)] 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)] @@ -28,7 +34,11 @@ ruma_api! { impl<'a> Request<'a> { /// Creates a new `Request` with the given room id. pub fn new(room_id: &'a RoomId) -> Self { - Self { room_id } + Self { + room_id, + #[cfg(feature = "unstable-pre-spec")] + reason: None, + } } } diff --git a/crates/ruma-events/src/room/member.rs b/crates/ruma-events/src/room/member.rs index 2f8916e6..af029788 100644 --- a/crates/ruma-events/src/room/member.rs +++ b/crates/ruma-events/src/room/member.rs @@ -79,6 +79,12 @@ pub struct MemberEventContent { #[serde(rename = "xyz.amorgan.blurhash")] #[serde(skip_serializing_if = "Option::is_none")] pub blurhash: Option, + + /// 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, } impl MemberEventContent { @@ -92,6 +98,8 @@ impl MemberEventContent { third_party_invite: None, #[cfg(feature = "unstable-pre-spec")] blurhash: None, + #[cfg(feature = "unstable-pre-spec")] + reason: None, } } } @@ -241,6 +249,8 @@ fn membership_change( third_party_invite: None, #[cfg(feature = "unstable-pre-spec")] blurhash: None, + #[cfg(feature = "unstable-pre-spec")] + reason: None, } };