Merge remote-tracking branch 'upstream/main' into conduwuit-changes

This commit is contained in:
strawberry 2024-09-28 17:09:18 -04:00
commit ade2f1daf0
6 changed files with 45 additions and 13 deletions

View File

@ -15,6 +15,8 @@ Breaking changes:
Improvements: 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 - Add support for MSC4108 OIDC sign in and E2EE set up via QR code
- Heroes in `sync::sync_events::v4`: `SyncRequestList` and `RoomSubscription` - Heroes in `sync::sync_events::v4`: `SyncRequestList` and `RoomSubscription`
both have a new `include_heroes` field. `SlidingSyncRoom` has a new `heroes` 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 - 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

@ -43,6 +43,15 @@ pub struct Capabilities {
#[serde(rename = "m.3pid_changes", default)] #[serde(rename = "m.3pid_changes", default)]
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)]
@ -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)] #[cfg(test)]
mod tests { mod tests {
use std::borrow::Cow; use std::borrow::Cow;

View File

@ -981,7 +981,7 @@ impl From<v5::request::List> for SyncRequestList {
#[cfg(feature = "unstable-msc4186")] #[cfg(feature = "unstable-msc4186")]
impl From<v5::request::RoomDetails> for RoomDetailsConfig { impl From<v5::request::RoomDetails> for RoomDetailsConfig {
fn from(value: v5::request::RoomDetails) -> Self { 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<v5::request::RoomSubscription> for RoomSubscription {
fn from(value: v5::request::RoomSubscription) -> Self { fn from(value: v5::request::RoomSubscription) -> Self {
Self { Self {
required_state: value.required_state, required_state: value.required_state,
timeline_limit: value.timeline_limit, timeline_limit: Some(value.timeline_limit),
include_heroes: value.include_heroes, include_heroes: value.include_heroes,
} }
} }

View File

@ -154,8 +154,7 @@ pub mod request {
pub required_state: Vec<(StateEventType, String)>, pub required_state: Vec<(StateEventType, String)>,
/// The maximum number of timeline events to return per room. /// The maximum number of timeline events to return per room.
#[serde(skip_serializing_if = "Option::is_none")] pub timeline_limit: UInt,
pub timeline_limit: Option<UInt>,
/// Include the room heroes. /// Include the room heroes.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -171,8 +170,7 @@ pub mod request {
pub required_state: Vec<(StateEventType, String)>, pub required_state: Vec<(StateEventType, String)>,
/// The maximum number of timeline events to return per room. /// The maximum number of timeline events to return per room.
#[serde(skip_serializing_if = "Option::is_none")] pub timeline_limit: UInt,
pub timeline_limit: Option<UInt>,
} }
/// Sliding sync request extensions (see [`super::Request::extensions`]). /// Sliding sync request extensions (see [`super::Request::extensions`]).
@ -420,10 +418,6 @@ pub mod request {
/// Response type for the `/sync` endpoint. /// Response type for the `/sync` endpoint.
#[response(error = crate::Error)] #[response(error = crate::Error)]
pub struct Response { 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`]). /// Matches the `txn_id` sent by the request (see [`Request::txn_id`]).
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub txn_id: Option<String>, pub txn_id: Option<String>,
@ -449,7 +443,6 @@ impl Response {
/// Creates a new `Response` with the given `pos`. /// Creates a new `Response` with the given `pos`.
pub fn new(pos: String) -> Self { pub fn new(pos: String) -> Self {
Self { Self {
initial: Default::default(),
txn_id: None, txn_id: None,
pos, pos,
lists: Default::default(), lists: Default::default(),
@ -737,7 +730,6 @@ impl From<v4::Response> for Response {
fn from(value: v4::Response) -> Self { fn from(value: v4::Response) -> Self {
Self { Self {
pos: value.pos, pos: value.pos,
initial: value.initial,
txn_id: value.txn_id, txn_id: value.txn_id,
lists: value.lists.into_iter().map(|(room_id, list)| (room_id, list.into())).collect(), 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(), rooms: value.rooms.into_iter().map(|(room_id, room)| (room_id, room.into())).collect(),

View File

@ -1,5 +1,10 @@
# [unreleased] # [unreleased]
Bug fixes:
- `ServerSigningKeys` can be deserialized when `old_verify_keys` is missing, due to a
clarification in the spec.
Improvements: Improvements:
- Add support for authenticated media endpoints, according to MSC3916 / Matrix 1.11 - Add support for authenticated media endpoints, according to MSC3916 / Matrix 1.11

View File

@ -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. /// Queried server key, signed by the notary server.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
@ -60,6 +59,9 @@ pub struct ServerSigningKeys {
pub verify_keys: BTreeMap<OwnedServerSigningKeyId, VerifyKey>, pub verify_keys: BTreeMap<OwnedServerSigningKeyId, VerifyKey>,
/// Public keys that the homeserver used to use and when it stopped using them. /// 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<OwnedServerSigningKeyId, OldVerifyKey>, pub old_verify_keys: BTreeMap<OwnedServerSigningKeyId, OldVerifyKey>,
/// Digital signatures of this object signed using the verify_keys. /// Digital signatures of this object signed using the verify_keys.