client-api: Add m.get_login_token capability

According to a clarification in the spec.
This commit is contained in:
Kévin Commaille 2024-09-05 11:46:33 +02:00 committed by Kévin Commaille
parent 85b412ffed
commit 12a2e9342b
2 changed files with 31 additions and 0 deletions

View File

@ -34,6 +34,8 @@ Improvements:
- Change types of `SyncRequestListFilters::{room_types,not_room_types}` to - Change types of `SyncRequestListFilters::{room_types,not_room_types}` to
`Vec<RoomTypeFilter>` instead of a vector of strings `Vec<RoomTypeFilter>` instead of a vector of strings
- This is a breaking change, but only for users of `unstable-msc3575` - This is a breaking change, but only for users of `unstable-msc3575`
- Add the `get_login_token` field to `Capabilities`, according to a
clarification in the spec.
Bug fixes: Bug fixes:

View File

@ -63,6 +63,15 @@ pub struct Capabilities {
)] )]
pub thirdparty_id_changes: ThirdPartyIdChangesCapability, pub thirdparty_id_changes: ThirdPartyIdChangesCapability,
/// Capability to indicate if the user can generate tokens to log further clients into their
/// account.
#[serde(
rename = "m.get_login_token",
default,
skip_serializing_if = "GetLoginTokenCapability::is_default"
)]
pub get_login_token: GetLoginTokenCapability,
/// Any other custom capabilities that the server supports outside of the specification, /// Any other custom capabilities that the server supports outside of the specification,
/// labeled using the Java package naming convention and stored as arbitrary JSON values. /// labeled using the Java package naming convention and stored as arbitrary JSON values.
#[serde(flatten)] #[serde(flatten)]
@ -292,6 +301,26 @@ impl Default for ThirdPartyIdChangesCapability {
} }
} }
/// Information about the `m.get_login_token` capability.
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct GetLoginTokenCapability {
/// Whether the user can request a login token.
pub enabled: bool,
}
impl GetLoginTokenCapability {
/// Creates a new `GetLoginTokenCapability` with the given enabled flag.
pub fn new(enabled: bool) -> Self {
Self { enabled }
}
/// Returns whether all fields have their default value.
pub fn is_default(&self) -> bool {
!self.enabled
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::borrow::Cow; use std::borrow::Cow;