client-api: Add the reason field for remaining endpoints (MSC2367)

This commit is contained in:
Niklas Kunz 2021-09-23 18:18:49 +02:00 committed by GitHub
parent a7be60d9eb
commit efd5ad52fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 5 deletions

View File

@ -1,5 +1,17 @@
# [unreleased] # [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 # 0.12.3
* Add a `feature = "compat"` workaround for Element failing on `GET /_matrix/client/r0/account/3pid` * Add a `feature = "compat"` workaround for Element failing on `GET /_matrix/client/r0/account/3pid`

View File

@ -30,8 +30,14 @@ ruma_api! {
pub room_id: &'a RoomId, pub room_id: &'a RoomId,
/// The user to invite. /// The user to invite.
#[ruma_api(body)] #[serde(flatten)]
pub recipient: InvitationRecipient<'a>, 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)] #[derive(Default)]
@ -43,7 +49,12 @@ ruma_api! {
impl<'a> Request<'a> { impl<'a> Request<'a> {
/// Creates a new `Request` with the given room ID and invitation recipient. /// Creates a new `Request` with the given room ID and invitation recipient.
pub fn new(room_id: &'a RoomId, recipient: InvitationRecipient<'a>) -> Self { 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,
}
} }
} }

View File

@ -24,6 +24,12 @@ ruma_api! {
/// party identity which has been invited to the room. /// party identity which has been invited to the room.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub third_party_signed: Option<ThirdPartySigned<'a>>, pub third_party_signed: Option<ThirdPartySigned<'a>>,
/// 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: { response: {
@ -37,7 +43,12 @@ 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, third_party_signed: None } Self {
room_id,
third_party_signed: None,
#[cfg(feature = "unstable-pre-spec")]
reason: None,
}
} }
} }

View File

@ -30,6 +30,12 @@ ruma_api! {
/// party identity which has been invited to the room. /// party identity which has been invited to the room.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub third_party_signed: Option<ThirdPartySigned<'a>>, pub third_party_signed: Option<ThirdPartySigned<'a>>,
/// 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: { response: {
@ -43,7 +49,13 @@ ruma_api! {
impl<'a> Request<'a> { impl<'a> Request<'a> {
/// Creates a new `Request` with the given room ID or alias ID. /// Creates a new `Request` with the given room ID or alias ID.
pub fn new(room_id_or_alias: &'a RoomIdOrAliasId) -> Self { 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,
}
} }
} }

View File

@ -20,6 +20,12 @@ ruma_api! {
/// The user to unban. /// The user to unban.
pub user_id: &'a UserId, 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)] #[derive(Default)]
@ -31,7 +37,12 @@ ruma_api! {
impl<'a> Request<'a> { impl<'a> Request<'a> {
/// Creates a new `Request` with the given room id and room id. /// Creates a new `Request` with the given room id and room id.
pub fn new(room_id: &'a RoomId, user_id: &'a UserId) -> Self { 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,
}
} }
} }