diff --git a/crates/ruma-client-api/CHANGELOG.md b/crates/ruma-client-api/CHANGELOG.md index 244dfb06..a05f50de 100644 --- a/crates/ruma-client-api/CHANGELOG.md +++ b/crates/ruma-client-api/CHANGELOG.md @@ -1,5 +1,17 @@ # [unreleased] +Improvements: + +* Add unstable support for reasons in the membership endpoints: + ```rust + r0::membership::{ + join_room_by_id, + join_room_by_id_or_alias, + invite_user, + unban_user + } + ``` + # 0.12.3 * Add a `feature = "compat"` workaround for Element failing on `GET /_matrix/client/r0/account/3pid` diff --git a/crates/ruma-client-api/src/r0/membership/invite_user.rs b/crates/ruma-client-api/src/r0/membership/invite_user.rs index b4558adf..997091bf 100644 --- a/crates/ruma-client-api/src/r0/membership/invite_user.rs +++ b/crates/ruma-client-api/src/r0/membership/invite_user.rs @@ -30,8 +30,14 @@ ruma_api! { pub room_id: &'a RoomId, /// The user to invite. - #[ruma_api(body)] + #[serde(flatten)] pub recipient: InvitationRecipient<'a>, + + /// Optional reason for inviting the user. + #[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)] @@ -43,7 +49,12 @@ ruma_api! { impl<'a> Request<'a> { /// Creates a new `Request` with the given room ID and invitation recipient. pub fn new(room_id: &'a RoomId, recipient: InvitationRecipient<'a>) -> Self { - Self { room_id, recipient } + Self { + room_id, + recipient, + #[cfg(feature = "unstable-pre-spec")] + reason: None, + } } } diff --git a/crates/ruma-client-api/src/r0/membership/join_room_by_id.rs b/crates/ruma-client-api/src/r0/membership/join_room_by_id.rs index bc8d53d5..5d6ac07d 100644 --- a/crates/ruma-client-api/src/r0/membership/join_room_by_id.rs +++ b/crates/ruma-client-api/src/r0/membership/join_room_by_id.rs @@ -24,6 +24,12 @@ ruma_api! { /// party identity which has been invited to the room. #[serde(skip_serializing_if = "Option::is_none")] pub third_party_signed: Option>, + + /// Optional reason for joining the 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<&'a str>, } response: { @@ -37,7 +43,12 @@ 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, third_party_signed: None } + Self { + room_id, + third_party_signed: None, + #[cfg(feature = "unstable-pre-spec")] + reason: None, + } } } diff --git a/crates/ruma-client-api/src/r0/membership/join_room_by_id_or_alias.rs b/crates/ruma-client-api/src/r0/membership/join_room_by_id_or_alias.rs index f2af3b5f..11e4535a 100644 --- a/crates/ruma-client-api/src/r0/membership/join_room_by_id_or_alias.rs +++ b/crates/ruma-client-api/src/r0/membership/join_room_by_id_or_alias.rs @@ -30,6 +30,12 @@ ruma_api! { /// party identity which has been invited to the room. #[serde(skip_serializing_if = "Option::is_none")] pub third_party_signed: Option>, + + /// Optional reason for joining the 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<&'a str>, } response: { @@ -43,7 +49,13 @@ ruma_api! { impl<'a> Request<'a> { /// Creates a new `Request` with the given room ID or alias ID. pub fn new(room_id_or_alias: &'a RoomIdOrAliasId) -> Self { - Self { room_id_or_alias, server_name: &[], third_party_signed: None } + Self { + room_id_or_alias, + server_name: &[], + third_party_signed: None, + #[cfg(feature = "unstable-pre-spec")] + reason: None, + } } } diff --git a/crates/ruma-client-api/src/r0/membership/unban_user.rs b/crates/ruma-client-api/src/r0/membership/unban_user.rs index 2952ae6d..97cc8866 100644 --- a/crates/ruma-client-api/src/r0/membership/unban_user.rs +++ b/crates/ruma-client-api/src/r0/membership/unban_user.rs @@ -20,6 +20,12 @@ ruma_api! { /// The user to unban. pub user_id: &'a UserId, + + /// Optional reason for unbanning the user. + #[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)] @@ -31,7 +37,12 @@ ruma_api! { impl<'a> Request<'a> { /// Creates a new `Request` with the given room id and room id. pub fn new(room_id: &'a RoomId, user_id: &'a UserId) -> Self { - Self { room_id, user_id } + Self { + room_id, + user_id, + #[cfg(feature = "unstable-pre-spec")] + reason: None, + } } }