diff --git a/crates/ruma-client-api/CHANGELOG.md b/crates/ruma-client-api/CHANGELOG.md index bce33bf0..580b1a3e 100644 --- a/crates/ruma-client-api/CHANGELOG.md +++ b/crates/ruma-client-api/CHANGELOG.md @@ -15,6 +15,8 @@ Breaking changes: Improvements: +- Add support for MSC4186, aka simplified sliding sync, behind + `unstable-msc4186`. - Add support for MSC4108 OIDC sign in and E2EE set up via QR code - Heroes in `sync::sync_events::v4`: `SyncRequestList` and `RoomSubscription` both have a new `include_heroes` field. `SlidingSyncRoom` has a new `heroes` @@ -32,6 +34,8 @@ Improvements: - Change types of `SyncRequestListFilters::{room_types,not_room_types}` to `Vec` instead of a vector of strings - 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: diff --git a/crates/ruma-client-api/src/discovery/get_capabilities.rs b/crates/ruma-client-api/src/discovery/get_capabilities.rs index 0e868ac0..d0e1f398 100644 --- a/crates/ruma-client-api/src/discovery/get_capabilities.rs +++ b/crates/ruma-client-api/src/discovery/get_capabilities.rs @@ -43,6 +43,15 @@ pub struct Capabilities { #[serde(rename = "m.3pid_changes", default)] 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, /// labeled using the Java package naming convention and stored as arbitrary JSON values. #[serde(flatten)] @@ -272,6 +281,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)] mod tests { use std::borrow::Cow; diff --git a/crates/ruma-client-api/src/sync/sync_events/v4.rs b/crates/ruma-client-api/src/sync/sync_events/v4.rs index 604d5ccc..406ba2a0 100644 --- a/crates/ruma-client-api/src/sync/sync_events/v4.rs +++ b/crates/ruma-client-api/src/sync/sync_events/v4.rs @@ -981,7 +981,7 @@ impl From for SyncRequestList { #[cfg(feature = "unstable-msc4186")] impl From for RoomDetailsConfig { fn from(value: v5::request::RoomDetails) -> Self { - Self { required_state: value.required_state, timeline_limit: value.timeline_limit } + Self { required_state: value.required_state, timeline_limit: Some(value.timeline_limit) } } } @@ -1001,7 +1001,7 @@ impl From for RoomSubscription { fn from(value: v5::request::RoomSubscription) -> Self { Self { required_state: value.required_state, - timeline_limit: value.timeline_limit, + timeline_limit: Some(value.timeline_limit), include_heroes: value.include_heroes, } } diff --git a/crates/ruma-client-api/src/sync/sync_events/v5.rs b/crates/ruma-client-api/src/sync/sync_events/v5.rs index 24e7f1bd..4be8c914 100644 --- a/crates/ruma-client-api/src/sync/sync_events/v5.rs +++ b/crates/ruma-client-api/src/sync/sync_events/v5.rs @@ -154,8 +154,7 @@ pub mod request { pub required_state: Vec<(StateEventType, String)>, /// The maximum number of timeline events to return per room. - #[serde(skip_serializing_if = "Option::is_none")] - pub timeline_limit: Option, + pub timeline_limit: UInt, /// Include the room heroes. #[serde(skip_serializing_if = "Option::is_none")] @@ -171,8 +170,7 @@ pub mod request { pub required_state: Vec<(StateEventType, String)>, /// The maximum number of timeline events to return per room. - #[serde(skip_serializing_if = "Option::is_none")] - pub timeline_limit: Option, + pub timeline_limit: UInt, } /// Sliding sync request extensions (see [`super::Request::extensions`]). @@ -420,10 +418,6 @@ pub mod request { /// Response type for the `/sync` endpoint. #[response(error = crate::Error)] pub struct Response { - /// Whether this response describes an initial sync. - #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] - pub initial: bool, - /// Matches the `txn_id` sent by the request (see [`Request::txn_id`]). #[serde(skip_serializing_if = "Option::is_none")] pub txn_id: Option, @@ -449,7 +443,6 @@ impl Response { /// Creates a new `Response` with the given `pos`. pub fn new(pos: String) -> Self { Self { - initial: Default::default(), txn_id: None, pos, lists: Default::default(), @@ -737,7 +730,6 @@ impl From for Response { fn from(value: v4::Response) -> Self { Self { pos: value.pos, - initial: value.initial, txn_id: value.txn_id, lists: value.lists.into_iter().map(|(room_id, list)| (room_id, list.into())).collect(), rooms: value.rooms.into_iter().map(|(room_id, room)| (room_id, room.into())).collect(), diff --git a/crates/ruma-federation-api/CHANGELOG.md b/crates/ruma-federation-api/CHANGELOG.md index edd0899d..88a176fa 100644 --- a/crates/ruma-federation-api/CHANGELOG.md +++ b/crates/ruma-federation-api/CHANGELOG.md @@ -1,5 +1,10 @@ # [unreleased] +Bug fixes: + +- `ServerSigningKeys` can be deserialized when `old_verify_keys` is missing, due to a + clarification in the spec. + Improvements: - Add support for authenticated media endpoints, according to MSC3916 / Matrix 1.11 diff --git a/crates/ruma-federation-api/src/discovery.rs b/crates/ruma-federation-api/src/discovery.rs index 9ebb2368..b97bd609 100644 --- a/crates/ruma-federation-api/src/discovery.rs +++ b/crates/ruma-federation-api/src/discovery.rs @@ -48,7 +48,6 @@ impl OldVerifyKey { } } -// Spec is wrong, all fields are required (see https://github.com/matrix-org/matrix-spec/issues/613) /// Queried server key, signed by the notary server. #[derive(Clone, Debug, Deserialize, Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] @@ -60,6 +59,9 @@ pub struct ServerSigningKeys { pub verify_keys: BTreeMap, /// Public keys that the homeserver used to use and when it stopped using them. + // This field is optional, but all fields were assumed to be required before clarification + // in https://github.com/matrix-org/matrix-spec/pull/1930, so we still send it. + #[serde(default)] pub old_verify_keys: BTreeMap, /// Digital signatures of this object signed using the verify_keys.