From af0259d135ea055f6b36af92313649458919ecb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Sun, 27 Oct 2024 14:23:40 +0100 Subject: [PATCH] refactor!: Upgrade Ruma to 0.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- Cargo.lock | 45 +++++++++++------- Cargo.toml | 4 +- bindings/matrix-sdk-crypto-ffi/src/machine.rs | 11 +++-- crates/matrix-sdk-base/src/client.rs | 47 ++++++++++++++----- crates/matrix-sdk-crypto/src/backups/mod.rs | 6 +-- .../src/gossiping/machine.rs | 4 +- crates/matrix-sdk-crypto/src/machine/mod.rs | 6 +-- .../src/machine/test_helpers.rs | 10 ++-- .../src/machine/tests/mod.rs | 8 ++-- crates/matrix-sdk-crypto/src/olm/account.rs | 47 +++++++++---------- .../src/session_manager/group_sessions/mod.rs | 4 +- .../src/session_manager/sessions.rs | 8 ++-- .../src/types/one_time_keys.rs | 26 +++++----- .../src/notification_settings/command.rs | 19 ++++---- .../src/notification_settings/mod.rs | 26 ++++------ .../notification_settings/rule_commands.rs | 45 +++++------------- .../src/notification_settings/rules.rs | 6 +-- crates/matrix-sdk/src/room/mod.rs | 4 +- crates/matrix-sdk/src/sliding_sync/mod.rs | 6 ++- .../integration/encryption/verification.rs | 8 ++-- 20 files changed, 178 insertions(+), 162 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be9c9a99775..f3c3d638016 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4574,8 +4574,9 @@ dependencies = [ [[package]] name = "ruma" -version = "0.10.1" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d719b9e1ce5b34a1e0b6e2ba4707f7923ce7fb3474881d771466456d68f3e485" dependencies = [ "assign", "js_int", @@ -4591,8 +4592,9 @@ dependencies = [ [[package]] name = "ruma-client-api" -version = "0.18.0" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "325e054db8d5545c00767d9868356d61e63f2c6cb8b54768346d66696ea4ad48" dependencies = [ "as_variant", "assign", @@ -4614,8 +4616,9 @@ dependencies = [ [[package]] name = "ruma-common" -version = "0.13.0" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4717eb215175df5087fdd79da2c9a4198c9a50fe747db0afbc23c8ac18a25da8" dependencies = [ "as_variant", "base64 0.22.1", @@ -4646,8 +4649,9 @@ dependencies = [ [[package]] name = "ruma-events" -version = "0.28.1" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "969cfed397d22f0338d99457409aa9c9dd4def4a5ce8d6567e914a320bad30da" dependencies = [ "as_variant", "indexmap 2.6.0", @@ -4671,8 +4675,9 @@ dependencies = [ [[package]] name = "ruma-federation-api" -version = "0.9.0" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5a09ac22b3352bf7a350514dc9a87e1b56aba04c326ac9ce142740f7218afa" dependencies = [ "http", "js_int", @@ -4685,8 +4690,9 @@ dependencies = [ [[package]] name = "ruma-html" -version = "0.2.0" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7571886b6df90a4ed72e7481a5a39cc2a5b3a4e956e9366ad798e4e2e9fe8005" dependencies = [ "as_variant", "html5ever", @@ -4697,8 +4703,9 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" -version = "0.9.5" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7f9b534a65698d7db3c08d94bf91de0046fe6c7893a7b360502f65e7011ac4" dependencies = [ "js_int", "thiserror", @@ -4706,8 +4713,9 @@ dependencies = [ [[package]] name = "ruma-macros" -version = "0.13.0" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d57d3cb20e8e758e8f7c5e408ce831d46758003b615100099852e468631934" dependencies = [ "cfg-if", "once_cell", @@ -4722,8 +4730,9 @@ dependencies = [ [[package]] name = "ruma-push-gateway-api" -version = "0.9.0" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfced466fbed6277f74ac3887eeb96c185a09f4323dc3c39bcea04870430fe9a" dependencies = [ "js_int", "ruma-common", diff --git a/Cargo.toml b/Cargo.toml index d648226e1fc..8ad1eacd0f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ once_cell = "1.16.0" pin-project-lite = "0.2.9" rand = "0.8.5" reqwest = { version = "0.12.4", default-features = false } -ruma = { git = "https://github.com/ruma/ruma", rev = "26165b23fc2ae9928c5497a21db3d31f4b44cc2a", features = [ +ruma = { version = "0.11.0", features = [ "client-api-c", "compat-upload-signatures", "compat-user-id", @@ -59,7 +59,7 @@ ruma = { git = "https://github.com/ruma/ruma", rev = "26165b23fc2ae9928c5497a21d "unstable-msc4075", "unstable-msc4140", ] } -ruma-common = { git = "https://github.com/ruma/ruma", rev = "26165b23fc2ae9928c5497a21db3d31f4b44cc2a" } +ruma-common = "0.14.0" serde = "1.0.151" serde_html_form = "0.2.0" serde_json = "1.0.91" diff --git a/bindings/matrix-sdk-crypto-ffi/src/machine.rs b/bindings/matrix-sdk-crypto-ffi/src/machine.rs index da12075bfe4..6403379ac6c 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/machine.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/machine.rs @@ -42,7 +42,8 @@ use ruma::{ }, serde::Raw, to_device::DeviceIdOrAllDevices, - DeviceKeyAlgorithm, EventId, OwnedTransactionId, OwnedUserId, RoomId, UserId, + DeviceKeyAlgorithm, EventId, OneTimeKeyAlgorithm, OwnedTransactionId, OwnedUserId, RoomId, + UserId, }; use serde::{Deserialize, Serialize}; use serde_json::{value::RawValue, Value}; @@ -528,11 +529,11 @@ impl OlmMachine { ) -> Result { let to_device: ToDevice = serde_json::from_str(&events)?; let device_changes: RumaDeviceLists = device_changes.into(); - let key_counts: BTreeMap = key_counts + let key_counts: BTreeMap = key_counts .into_iter() .map(|(k, v)| { ( - DeviceKeyAlgorithm::from(k), + OneTimeKeyAlgorithm::from(k), v.clamp(0, i32::MAX) .try_into() .expect("Couldn't convert key counts into an UInt"), @@ -540,8 +541,8 @@ impl OlmMachine { }) .collect(); - let unused_fallback_keys: Option> = - unused_fallback_keys.map(|u| u.into_iter().map(DeviceKeyAlgorithm::from).collect()); + let unused_fallback_keys: Option> = + unused_fallback_keys.map(|u| u.into_iter().map(OneTimeKeyAlgorithm::from).collect()); let (to_device_events, room_key_infos) = self.runtime.block_on( self.inner.receive_sync_changes(matrix_sdk_crypto::EncryptionSyncChanges { diff --git a/crates/matrix-sdk-base/src/client.rs b/crates/matrix-sdk-base/src/client.rs index fdb798fdc09..95bd30e12f0 100644 --- a/crates/matrix-sdk-base/src/client.rs +++ b/crates/matrix-sdk-base/src/client.rs @@ -43,6 +43,7 @@ use ruma::{ api::client as api, events::{ ignored_user_list::IgnoredUserListEvent, + marked_unread::MarkedUnreadEventContent, push_rules::{PushRulesEvent, PushRulesEventContent}, room::{ member::{MembershipState, RoomMemberEventContent, SyncRoomMemberEvent}, @@ -683,6 +684,25 @@ impl BaseClient { } } + // Helper to update the unread marker for stable and unstable prefixes. + fn on_unread_marker( + room_id: &RoomId, + content: &MarkedUnreadEventContent, + room_info: &mut RoomInfo, + room_info_notable_updates: &mut BTreeMap, + ) { + if room_info.base_info.is_marked_unread != content.unread { + // Notify the room list about a manual read marker change if the + // value's changed. + room_info_notable_updates + .entry(room_id.to_owned()) + .or_default() + .insert(RoomInfoNotableUpdateReasons::UNREAD_MARKER); + } + + room_info.base_info.is_marked_unread = content.unread; + } + // Handle new events. for raw_event in events { match raw_event.deserialize() { @@ -692,19 +712,24 @@ impl BaseClient { match event { AnyRoomAccountDataEvent::MarkedUnread(event) => { on_room_info(room_id, changes, self, |room_info| { - if room_info.base_info.is_marked_unread != event.content.unread { - // Notify the room list about a manual read marker change if the - // value's changed. - room_info_notable_updates - .entry(room_id.to_owned()) - .or_default() - .insert(RoomInfoNotableUpdateReasons::UNREAD_MARKER); - } - - room_info.base_info.is_marked_unread = event.content.unread; + on_unread_marker( + room_id, + &event.content, + room_info, + room_info_notable_updates, + ); + }); + } + AnyRoomAccountDataEvent::UnstableMarkedUnread(event) => { + on_room_info(room_id, changes, self, |room_info| { + on_unread_marker( + room_id, + &event.content.0, + room_info, + room_info_notable_updates, + ); }); } - AnyRoomAccountDataEvent::Tag(event) => { on_room_info(room_id, changes, self, |room_info| { room_info.base_info.handle_notable_tags(&event.content.tags); diff --git a/crates/matrix-sdk-crypto/src/backups/mod.rs b/crates/matrix-sdk-crypto/src/backups/mod.rs index a3fe22fc1d2..fc98dfa03d0 100644 --- a/crates/matrix-sdk-crypto/src/backups/mod.rs +++ b/crates/matrix-sdk-crypto/src/backups/mod.rs @@ -224,19 +224,19 @@ impl BackupMachine { if device_key_id.algorithm() == DeviceKeyAlgorithm::Ed25519 { // No need to check our own device here, we're doing that using // the check_own_device_signature(). - if device_key_id.device_id() == self.store.static_account().device_id { + if device_key_id.key_name() == self.store.static_account().device_id { continue; } let state = self .test_ed25519_device_signature( - device_key_id.device_id(), + device_key_id.key_name(), signatures, auth_data, ) .await?; - result.insert(device_key_id.device_id().to_owned(), state); + result.insert(device_key_id.key_name().to_owned(), state); // Abort the loop if we found a trusted and valid signature, // unless we should check all of them. diff --git a/crates/matrix-sdk-crypto/src/gossiping/machine.rs b/crates/matrix-sdk-crypto/src/gossiping/machine.rs index 22a4e4e9cdd..9fa0bd9fdaf 100644 --- a/crates/matrix-sdk-crypto/src/gossiping/machine.rs +++ b/crates/matrix-sdk-crypto/src/gossiping/machine.rs @@ -34,7 +34,7 @@ use ruma::{ events::secret::request::{ RequestAction, SecretName, ToDeviceSecretRequestEvent as SecretRequestEvent, }, - DeviceId, DeviceKeyAlgorithm, OwnedDeviceId, OwnedTransactionId, OwnedUserId, RoomId, + DeviceId, OneTimeKeyAlgorithm, OwnedDeviceId, OwnedTransactionId, OwnedUserId, RoomId, TransactionId, UserId, }; use tracing::{debug, field::debug, info, instrument, trace, warn, Span}; @@ -178,7 +178,7 @@ impl GossipMachine { .map(|(key, value)| { let device_map = value .iter() - .map(|d| (d.to_owned(), DeviceKeyAlgorithm::SignedCurve25519)) + .map(|d| (d.to_owned(), OneTimeKeyAlgorithm::SignedCurve25519)) .collect(); (key.to_owned(), device_map) diff --git a/crates/matrix-sdk-crypto/src/machine/mod.rs b/crates/matrix-sdk-crypto/src/machine/mod.rs index 3624f4aa2cb..9439a83dea4 100644 --- a/crates/matrix-sdk-crypto/src/machine/mod.rs +++ b/crates/matrix-sdk-crypto/src/machine/mod.rs @@ -44,7 +44,7 @@ use ruma::{ AnyToDeviceEvent, MessageLikeEventContent, }, serde::{JsonObject, Raw}, - DeviceId, DeviceKeyAlgorithm, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedDeviceKeyId, + DeviceId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, OwnedDeviceId, OwnedDeviceKeyId, OwnedTransactionId, OwnedUserId, RoomId, TransactionId, UInt, UserId, }; use serde_json::{value::to_raw_value, Value}; @@ -2557,9 +2557,9 @@ pub struct EncryptionSyncChanges<'a> { /// sync response. pub changed_devices: &'a DeviceLists, /// The number of one time keys, as returned in the sync response. - pub one_time_keys_counts: &'a BTreeMap, + pub one_time_keys_counts: &'a BTreeMap, /// An optional list of fallback keys. - pub unused_fallback_keys: Option<&'a [DeviceKeyAlgorithm]>, + pub unused_fallback_keys: Option<&'a [OneTimeKeyAlgorithm]>, /// A next-batch token obtained from a to-device sync query. pub next_batch_token: Option, } diff --git a/crates/matrix-sdk-crypto/src/machine/test_helpers.rs b/crates/matrix-sdk-crypto/src/machine/test_helpers.rs index c1ace327dea..684b509436a 100644 --- a/crates/matrix-sdk-crypto/src/machine/test_helpers.rs +++ b/crates/matrix-sdk-crypto/src/machine/test_helpers.rs @@ -21,13 +21,15 @@ use as_variant::as_variant; use matrix_sdk_test::{ruma_response_from_json, test_json}; use ruma::{ api::client::keys::{ - claim_keys, get_keys, get_keys::v3::Response as KeysQueryResponse, upload_keys, + claim_keys, + get_keys::{self, v3::Response as KeysQueryResponse}, + upload_keys, }, device_id, encryption::OneTimeKey, events::dummy::ToDeviceDummyEventContent, serde::Raw, - user_id, DeviceId, OwnedDeviceKeyId, TransactionId, UserId, + user_id, DeviceId, OwnedOneTimeKeyId, TransactionId, UserId, }; use serde_json::json; @@ -37,7 +39,7 @@ use crate::{ }; /// These keys need to be periodically uploaded to the server. -type OneTimeKeys = BTreeMap>; +type OneTimeKeys = BTreeMap>; fn alice_device_id() -> &'static DeviceId { device_id!("JLAFKJWSCS") @@ -178,7 +180,7 @@ pub async fn create_session( machine: &OlmMachine, user_id: &UserId, device_id: &DeviceId, - key_id: OwnedDeviceKeyId, + key_id: OwnedOneTimeKeyId, one_time_key: Raw, ) { let one_time_keys = BTreeMap::from([( diff --git a/crates/matrix-sdk-crypto/src/machine/tests/mod.rs b/crates/matrix-sdk-crypto/src/machine/tests/mod.rs index 21dabf2023a..0de4cbcc8ad 100644 --- a/crates/matrix-sdk-crypto/src/machine/tests/mod.rs +++ b/crates/matrix-sdk-crypto/src/machine/tests/mod.rs @@ -37,7 +37,7 @@ use ruma::{ room_id, serde::Raw, uint, user_id, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch, - TransactionId, UserId, + OneTimeKeyAlgorithm, TransactionId, UserId, }; use serde_json::json; use vodozemac::{ @@ -174,7 +174,7 @@ async fn test_generate_one_time_keys() { .await .unwrap(); - response.one_time_key_counts.insert(DeviceKeyAlgorithm::SignedCurve25519, uint!(50)); + response.one_time_key_counts.insert(OneTimeKeyAlgorithm::SignedCurve25519, uint!(50)); machine.receive_keys_upload_response(&response).await.unwrap(); @@ -275,7 +275,7 @@ fn test_one_time_key_signing() { async fn test_keys_for_upload() { let machine = OlmMachine::new(user_id(), alice_device_id()).await; - let key_counts = BTreeMap::from([(DeviceKeyAlgorithm::SignedCurve25519, 49u8.into())]); + let key_counts = BTreeMap::from([(OneTimeKeyAlgorithm::SignedCurve25519, 49u8.into())]); machine .receive_sync_changes(EncryptionSyncChanges { to_device_events: Vec::new(), @@ -327,7 +327,7 @@ async fn test_keys_for_upload() { let mut response = keys_upload_response(); response.one_time_key_counts.insert( - DeviceKeyAlgorithm::SignedCurve25519, + OneTimeKeyAlgorithm::SignedCurve25519, account.max_one_time_keys().try_into().unwrap(), ); diff --git a/crates/matrix-sdk-crypto/src/olm/account.rs b/crates/matrix-sdk-crypto/src/olm/account.rs index 27fc53ab73d..ac01502566c 100644 --- a/crates/matrix-sdk-crypto/src/olm/account.rs +++ b/crates/matrix-sdk-crypto/src/olm/account.rs @@ -31,8 +31,9 @@ use ruma::{ }, events::AnyToDeviceEvent, serde::Raw, - DeviceId, DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch, OwnedDeviceId, - OwnedDeviceKeyId, OwnedUserId, RoomId, SecondsSinceUnixEpoch, UInt, UserId, + DeviceId, DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, + OneTimeKeyId, OwnedDeviceId, OwnedDeviceKeyId, OwnedOneTimeKeyId, OwnedUserId, RoomId, + SecondsSinceUnixEpoch, UInt, UserId, }; use serde::{de::Error, Deserialize, Serialize}; use serde_json::{ @@ -403,7 +404,7 @@ impl fmt::Debug for Account { } } -pub type OneTimeKeys = BTreeMap>; +pub type OneTimeKeys = BTreeMap>; pub type FallbackKeys = OneTimeKeys; impl Account { @@ -521,10 +522,10 @@ impl Account { pub(crate) fn update_key_counts( &mut self, - one_time_key_counts: &BTreeMap, - unused_fallback_keys: Option<&[DeviceKeyAlgorithm]>, + one_time_key_counts: &BTreeMap, + unused_fallback_keys: Option<&[OneTimeKeyAlgorithm]>, ) { - if let Some(count) = one_time_key_counts.get(&DeviceKeyAlgorithm::SignedCurve25519) { + if let Some(count) = one_time_key_counts.get(&OneTimeKeyAlgorithm::SignedCurve25519) { let count: u64 = (*count).into(); let old_count = self.uploaded_key_count(); @@ -827,9 +828,7 @@ impl Account { /// Sign and prepare one-time keys to be uploaded. /// /// If no one-time keys need to be uploaded, returns an empty `BTreeMap`. - pub fn signed_one_time_keys( - &self, - ) -> BTreeMap> { + pub fn signed_one_time_keys(&self) -> OneTimeKeys { let one_time_keys = self.one_time_keys(); if one_time_keys.is_empty() { @@ -842,9 +841,7 @@ impl Account { /// Sign and prepare fallback keys to be uploaded. /// /// If no fallback keys need to be uploaded returns an empty BTreeMap. - pub fn signed_fallback_keys( - &self, - ) -> BTreeMap> { + pub fn signed_fallback_keys(&self) -> FallbackKeys { let fallback_key = self.fallback_key(); if fallback_key.is_empty() { @@ -858,15 +855,15 @@ impl Account { &self, keys: HashMap, fallback: bool, - ) -> BTreeMap> { + ) -> OneTimeKeys { let mut keys_map = BTreeMap::new(); for (key_id, key) in keys { let signed_key = self.sign_key(key, fallback); keys_map.insert( - DeviceKeyId::from_parts( - DeviceKeyAlgorithm::SignedCurve25519, + OneTimeKeyId::from_parts( + OneTimeKeyAlgorithm::SignedCurve25519, key_id.to_base64().as_str().into(), ), signed_key.into_raw(), @@ -949,7 +946,7 @@ impl Account { )] fn find_pre_key_bundle( device: &DeviceData, - key_map: &BTreeMap>, + key_map: &OneTimeKeys, ) -> Result { let mut keys = key_map.iter(); @@ -994,7 +991,7 @@ impl Account { pub fn create_outbound_session( &self, device: &DeviceData, - key_map: &BTreeMap>, + key_map: &OneTimeKeys, our_device_keys: DeviceKeys, ) -> Result { let pre_key_bundle = Self::find_pre_key_bundle(device, key_map)?; @@ -1502,8 +1499,8 @@ mod tests { use anyhow::Result; use matrix_sdk_test::async_test; use ruma::{ - device_id, user_id, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch, - UserId, + device_id, user_id, DeviceId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, + OneTimeKeyId, UserId, }; use serde_json::json; @@ -1532,12 +1529,12 @@ mod tests { let (_, second_one_time_keys, _) = account.keys_for_upload(); assert!(!second_one_time_keys.is_empty()); - let device_key_ids: BTreeSet<&DeviceKeyId> = + let one_time_key_ids: BTreeSet<&OneTimeKeyId> = one_time_keys.keys().map(Deref::deref).collect(); - let second_device_key_ids: BTreeSet<&DeviceKeyId> = + let second_one_time_key_ids: BTreeSet<&OneTimeKeyId> = second_one_time_keys.keys().map(Deref::deref).collect(); - assert_eq!(device_key_ids, second_device_key_ids); + assert_eq!(one_time_key_ids, second_one_time_key_ids); account.mark_keys_as_published(); account.update_uploaded_key_count(50); @@ -1552,10 +1549,10 @@ mod tests { let (_, fourth_one_time_keys, _) = account.keys_for_upload(); assert!(!fourth_one_time_keys.is_empty()); - let fourth_device_key_ids: BTreeSet<&DeviceKeyId> = + let fourth_one_time_key_ids: BTreeSet<&OneTimeKeyId> = fourth_one_time_keys.keys().map(Deref::deref).collect(); - assert_ne!(device_key_ids, fourth_device_key_ids); + assert_ne!(one_time_key_ids, fourth_one_time_key_ids); Ok(()) } @@ -1573,7 +1570,7 @@ mod tests { "We should not upload fallback keys until we know if the server supports them." ); - let one_time_keys = BTreeMap::from([(DeviceKeyAlgorithm::SignedCurve25519, 50u8.into())]); + let one_time_keys = BTreeMap::from([(OneTimeKeyAlgorithm::SignedCurve25519, 50u8.into())]); // A `None` here means that the server doesn't support fallback keys, no // fallback key gets uploaded. diff --git a/crates/matrix-sdk-crypto/src/session_manager/group_sessions/mod.rs b/crates/matrix-sdk-crypto/src/session_manager/group_sessions/mod.rs index 06c4bef261f..1fc60ffd9c9 100644 --- a/crates/matrix-sdk-crypto/src/session_manager/group_sessions/mod.rs +++ b/crates/matrix-sdk-crypto/src/session_manager/group_sessions/mod.rs @@ -789,7 +789,7 @@ mod tests { events::room::history_visibility::HistoryVisibility, room_id, to_device::DeviceIdOrAllDevices, - user_id, DeviceId, DeviceKeyAlgorithm, TransactionId, UInt, UserId, + user_id, DeviceId, OneTimeKeyAlgorithm, TransactionId, UInt, UserId, }; use serde_json::{json, Value}; @@ -1347,7 +1347,7 @@ mod tests { let machine = OlmMachine::new(alice_id(), alice_device_id()).await; assert_let!(Ok(Some((txn_id, device_keys_request))) = machine.upload_device_keys().await); let device_keys_response = upload_keys::v3::Response::new(BTreeMap::from([( - DeviceKeyAlgorithm::SignedCurve25519, + OneTimeKeyAlgorithm::SignedCurve25519, UInt::new(device_keys_request.one_time_keys.len() as u64).unwrap(), )])); machine.mark_request_as_sent(&txn_id, &device_keys_response).await.unwrap(); diff --git a/crates/matrix-sdk-crypto/src/session_manager/sessions.rs b/crates/matrix-sdk-crypto/src/session_manager/sessions.rs index b6e7d850cb9..2ae2306c330 100644 --- a/crates/matrix-sdk-crypto/src/session_manager/sessions.rs +++ b/crates/matrix-sdk-crypto/src/session_manager/sessions.rs @@ -25,7 +25,7 @@ use ruma::{ }, assign, events::dummy::ToDeviceDummyEventContent, - DeviceId, DeviceKeyAlgorithm, OwnedDeviceId, OwnedDeviceKeyId, OwnedServerName, + DeviceId, OneTimeKeyAlgorithm, OwnedDeviceId, OwnedOneTimeKeyId, OwnedServerName, OwnedTransactionId, OwnedUserId, SecondsSinceUnixEpoch, ServerName, TransactionId, UserId, }; use tracing::{debug, error, info, instrument, warn}; @@ -261,7 +261,7 @@ impl SessionManager { missing_session_devices_by_user .entry(user_id.to_owned()) .or_default() - .insert(device_id, DeviceKeyAlgorithm::SignedCurve25519); + .insert(device_id, OneTimeKeyAlgorithm::SignedCurve25519); } } else { failed_devices_by_user @@ -279,7 +279,7 @@ impl SessionManager { missing_session_devices_by_user.entry(user.to_owned()).or_default().extend( device_ids .iter() - .map(|device_id| (device_id.clone(), DeviceKeyAlgorithm::SignedCurve25519)), + .map(|device_id| (device_id.clone(), OneTimeKeyAlgorithm::SignedCurve25519)), ); } @@ -346,7 +346,7 @@ impl SessionManager { failed_servers: &BTreeSet, one_time_keys: &BTreeMap< &OwnedUserId, - BTreeMap<&OwnedDeviceId, BTreeSet<&OwnedDeviceKeyId>>, + BTreeMap<&OwnedDeviceId, BTreeSet<&OwnedOneTimeKeyId>>, >, ) { // First check that the response is for the request we were expecting. diff --git a/crates/matrix-sdk-crypto/src/types/one_time_keys.rs b/crates/matrix-sdk-crypto/src/types/one_time_keys.rs index bb6457b6577..33943787286 100644 --- a/crates/matrix-sdk-crypto/src/types/one_time_keys.rs +++ b/crates/matrix-sdk-crypto/src/types/one_time_keys.rs @@ -20,7 +20,7 @@ use std::collections::BTreeMap; -use ruma::{serde::Raw, DeviceKeyAlgorithm}; +use ruma::{serde::Raw, OneTimeKeyAlgorithm}; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::{value::to_raw_value, Value}; use vodozemac::Curve25519PublicKey; @@ -110,24 +110,28 @@ pub enum OneTimeKey { } impl OneTimeKey { - /// Deserialize the [`OneTimeKey`] from a [`DeviceKeyAlgorithm`] and a Raw + /// Deserialize the [`OneTimeKey`] from a [`OneTimeKeyAlgorithm`] and a Raw /// JSON value. pub fn deserialize( - algorithm: DeviceKeyAlgorithm, + algorithm: OneTimeKeyAlgorithm, key: &Raw, ) -> Result { match algorithm { - DeviceKeyAlgorithm::Curve25519 => { - let key: String = key.deserialize_as()?; - Ok(OneTimeKey::Key( - Curve25519PublicKey::from_base64(&key).map_err(serde::de::Error::custom)?, - )) - } - DeviceKeyAlgorithm::SignedCurve25519 => { + OneTimeKeyAlgorithm::SignedCurve25519 => { let key: SignedKey = key.deserialize_as()?; Ok(OneTimeKey::SignedKey(key)) } - _ => Err(serde::de::Error::custom(format!("Unsupported key algorithm {algorithm}"))), + _ => match algorithm.as_str() { + "curve25519" => { + let key: String = key.deserialize_as()?; + Ok(OneTimeKey::Key( + Curve25519PublicKey::from_base64(&key).map_err(serde::de::Error::custom)?, + )) + } + _ => { + Err(serde::de::Error::custom(format!("Unsupported key algorithm {algorithm}"))) + } + }, } } } diff --git a/crates/matrix-sdk/src/notification_settings/command.rs b/crates/matrix-sdk/src/notification_settings/command.rs index ed87c9bb5b2..f73ce30feb4 100644 --- a/crates/matrix-sdk/src/notification_settings/command.rs +++ b/crates/matrix-sdk/src/notification_settings/command.rs @@ -1,7 +1,6 @@ use std::fmt::Debug; use ruma::{ - api::client::push::RuleScope, push::{ Action, NewConditionalPushRule, NewPatternedPushRule, NewPushRule, NewSimplePushRule, PushCondition, RuleKind, Tweak, @@ -15,17 +14,17 @@ use crate::NotificationSettingsError; #[derive(Clone, Debug)] pub(crate) enum Command { /// Set a new `Room` push rule - SetRoomPushRule { scope: RuleScope, room_id: OwnedRoomId, notify: bool }, + SetRoomPushRule { room_id: OwnedRoomId, notify: bool }, /// Set a new `Override` push rule matching a `RoomId` - SetOverridePushRule { scope: RuleScope, rule_id: String, room_id: OwnedRoomId, notify: bool }, + SetOverridePushRule { rule_id: String, room_id: OwnedRoomId, notify: bool }, /// Set a new push rule for a keyword. - SetKeywordPushRule { scope: RuleScope, keyword: String }, + SetKeywordPushRule { keyword: String }, /// Set whether a push rule is enabled - SetPushRuleEnabled { scope: RuleScope, kind: RuleKind, rule_id: String, enabled: bool }, + SetPushRuleEnabled { kind: RuleKind, rule_id: String, enabled: bool }, /// Delete a push rule - DeletePushRule { scope: RuleScope, kind: RuleKind, rule_id: String }, + DeletePushRule { kind: RuleKind, rule_id: String }, /// Set a list of actions - SetPushRuleActions { scope: RuleScope, kind: RuleKind, rule_id: String, actions: Vec }, + SetPushRuleActions { kind: RuleKind, rule_id: String, actions: Vec }, } fn get_notify_actions(notify: bool) -> Vec { @@ -40,13 +39,13 @@ impl Command { /// Tries to create a push rule corresponding to this command pub(crate) fn to_push_rule(&self) -> Result { match self { - Self::SetRoomPushRule { scope: _, room_id, notify } => { + Self::SetRoomPushRule { room_id, notify } => { // `Room` push rule for this `room_id` let new_rule = NewSimplePushRule::new(room_id.clone(), get_notify_actions(*notify)); Ok(NewPushRule::Room(new_rule)) } - Self::SetOverridePushRule { scope: _, rule_id, room_id, notify } => { + Self::SetOverridePushRule { rule_id, room_id, notify } => { // `Override` push rule matching this `room_id` let new_rule = NewConditionalPushRule::new( rule_id.clone(), @@ -59,7 +58,7 @@ impl Command { Ok(NewPushRule::Override(new_rule)) } - Self::SetKeywordPushRule { scope: _, keyword } => { + Self::SetKeywordPushRule { keyword } => { // `Content` push rule matching this keyword let new_rule = NewPatternedPushRule::new( keyword.clone(), diff --git a/crates/matrix-sdk/src/notification_settings/mod.rs b/crates/matrix-sdk/src/notification_settings/mod.rs index a5c153400e1..58a89f2c03e 100644 --- a/crates/matrix-sdk/src/notification_settings/mod.rs +++ b/crates/matrix-sdk/src/notification_settings/mod.rs @@ -451,44 +451,39 @@ impl NotificationSettings { let request_config = Some(RequestConfig::short_retry()); for command in &rule_commands.commands { match command { - Command::DeletePushRule { scope, kind, rule_id } => { - let request = delete_pushrule::v3::Request::new( - scope.clone(), - kind.clone(), - rule_id.clone(), - ); + Command::DeletePushRule { kind, rule_id } => { + let request = delete_pushrule::v3::Request::new(kind.clone(), rule_id.clone()); self.client.send(request, request_config).await.map_err(|error| { error!("Unable to delete {kind} push rule `{rule_id}`: {error}"); NotificationSettingsError::UnableToRemovePushRule })?; } - Command::SetRoomPushRule { scope, room_id, notify: _ } => { + Command::SetRoomPushRule { room_id, notify: _ } => { let push_rule = command.to_push_rule()?; - let request = set_pushrule::v3::Request::new(scope.clone(), push_rule); + let request = set_pushrule::v3::Request::new(push_rule); self.client.send(request, request_config).await.map_err(|error| { error!("Unable to set room push rule `{room_id}`: {error}"); NotificationSettingsError::UnableToAddPushRule })?; } - Command::SetOverridePushRule { scope, rule_id, room_id: _, notify: _ } => { + Command::SetOverridePushRule { rule_id, room_id: _, notify: _ } => { let push_rule = command.to_push_rule()?; - let request = set_pushrule::v3::Request::new(scope.clone(), push_rule); + let request = set_pushrule::v3::Request::new(push_rule); self.client.send(request, request_config).await.map_err(|error| { error!("Unable to set override push rule `{rule_id}`: {error}"); NotificationSettingsError::UnableToAddPushRule })?; } - Command::SetKeywordPushRule { scope, keyword: _ } => { + Command::SetKeywordPushRule { keyword: _ } => { let push_rule = command.to_push_rule()?; - let request = set_pushrule::v3::Request::new(scope.clone(), push_rule); + let request = set_pushrule::v3::Request::new(push_rule); self.client .send(request, request_config) .await .map_err(|_| NotificationSettingsError::UnableToAddPushRule)?; } - Command::SetPushRuleEnabled { scope, kind, rule_id, enabled } => { + Command::SetPushRuleEnabled { kind, rule_id, enabled } => { let request = set_pushrule_enabled::v3::Request::new( - scope.clone(), kind.clone(), rule_id.clone(), *enabled, @@ -498,9 +493,8 @@ impl NotificationSettings { NotificationSettingsError::UnableToUpdatePushRule })?; } - Command::SetPushRuleActions { scope, kind, rule_id, actions } => { + Command::SetPushRuleActions { kind, rule_id, actions } => { let request = set_pushrule_actions::v3::Request::new( - scope.clone(), kind.clone(), rule_id.clone(), actions.clone(), diff --git a/crates/matrix-sdk/src/notification_settings/rule_commands.rs b/crates/matrix-sdk/src/notification_settings/rule_commands.rs index 3ac2cda73d9..47956c412b1 100644 --- a/crates/matrix-sdk/src/notification_settings/rule_commands.rs +++ b/crates/matrix-sdk/src/notification_settings/rule_commands.rs @@ -1,5 +1,4 @@ use ruma::{ - api::client::push::RuleScope, push::{ Action, PredefinedContentRuleId, PredefinedOverrideRuleId, RemovePushRuleError, RuleKind, Ruleset, @@ -31,13 +30,8 @@ impl RuleCommands { notify: bool, ) -> Result<(), NotificationSettingsError> { let command = match kind { - RuleKind::Room => Command::SetRoomPushRule { - scope: RuleScope::Global, - room_id: room_id.to_owned(), - notify, - }, + RuleKind::Room => Command::SetRoomPushRule { room_id: room_id.to_owned(), notify }, RuleKind::Override => Command::SetOverridePushRule { - scope: RuleScope::Global, rule_id: room_id.to_string(), room_id: room_id.to_owned(), notify, @@ -60,7 +54,7 @@ impl RuleCommands { &mut self, keyword: String, ) -> Result<(), NotificationSettingsError> { - let command = Command::SetKeywordPushRule { scope: RuleScope::Global, keyword }; + let command = Command::SetKeywordPushRule { keyword }; self.rules.insert(command.to_push_rule()?, None, None)?; self.commands.push(command); @@ -75,7 +69,7 @@ impl RuleCommands { rule_id: String, ) -> Result<(), RemovePushRuleError> { self.rules.remove(kind.clone(), &rule_id)?; - self.commands.push(Command::DeletePushRule { scope: RuleScope::Global, kind, rule_id }); + self.commands.push(Command::DeletePushRule { kind, rule_id }); Ok(()) } @@ -90,7 +84,6 @@ impl RuleCommands { .set_enabled(kind.clone(), rule_id, enabled) .map_err(|_| NotificationSettingsError::RuleNotFound(rule_id.to_owned()))?; self.commands.push(Command::SetPushRuleEnabled { - scope: RuleScope::Global, kind, rule_id: rule_id.to_owned(), enabled, @@ -182,7 +175,6 @@ impl RuleCommands { .set_actions(kind.clone(), rule_id, actions.clone()) .map_err(|_| NotificationSettingsError::RuleNotFound(rule_id.to_owned()))?; self.commands.push(Command::SetPushRuleActions { - scope: RuleScope::Global, kind, rule_id: rule_id.to_owned(), actions, @@ -196,7 +188,6 @@ mod tests { use assert_matches::assert_matches; use matrix_sdk_test::async_test; use ruma::{ - api::client::push::RuleScope, push::{ Action, NewPushRule, NewSimplePushRule, PredefinedContentRuleId, PredefinedOverrideRuleId, PredefinedUnderrideRuleId, RemovePushRuleError, RuleKind, @@ -229,8 +220,7 @@ mod tests { // Exactly one command must have been created. assert_eq!(rule_commands.commands.len(), 1); assert_matches!(&rule_commands.commands[0], - Command::SetRoomPushRule { scope, room_id: command_room_id, notify } => { - assert_eq!(scope, &RuleScope::Global); + Command::SetRoomPushRule { room_id: command_room_id, notify } => { assert_eq!(command_room_id, &room_id); assert!(notify); } @@ -249,8 +239,7 @@ mod tests { // Exactly one command must have been created. assert_eq!(rule_commands.commands.len(), 1); assert_matches!(&rule_commands.commands[0], - Command::SetOverridePushRule { scope, room_id: command_room_id, rule_id, notify } => { - assert_eq!(scope, &RuleScope::Global); + Command::SetOverridePushRule {room_id: command_room_id, rule_id, notify } => { assert_eq!(command_room_id, &room_id); assert_eq!(rule_id, room_id.as_str()); assert!(notify); @@ -298,8 +287,7 @@ mod tests { // Exactly one command must have been created. assert_eq!(rule_commands.commands.len(), 1); assert_matches!(&rule_commands.commands[0], - Command::DeletePushRule { scope, kind, rule_id } => { - assert_eq!(scope, &RuleScope::Global); + Command::DeletePushRule { kind, rule_id } => { assert_eq!(kind, &RuleKind::Room); assert_eq!(rule_id, room_id.as_str()); } @@ -351,8 +339,7 @@ mod tests { // Exactly one command must have been created. assert_eq!(rule_commands.commands.len(), 1); assert_matches!(&rule_commands.commands[0], - Command::SetPushRuleEnabled { scope, kind, rule_id, enabled } => { - assert_eq!(scope, &RuleScope::Global); + Command::SetPushRuleEnabled { kind, rule_id, enabled } => { assert_eq!(kind, &RuleKind::Override); assert_eq!(rule_id, PredefinedOverrideRuleId::Reaction.as_str()); assert!(enabled); @@ -426,8 +413,7 @@ mod tests { assert_eq!(rule_commands.commands.len(), 3); assert_matches!(&rule_commands.commands[0], - Command::SetPushRuleEnabled { scope, kind, rule_id, enabled } => { - assert_eq!(scope, &RuleScope::Global); + Command::SetPushRuleEnabled { kind, rule_id, enabled } => { assert_eq!(kind, &RuleKind::Override); assert_eq!(rule_id, PredefinedOverrideRuleId::IsUserMention.as_str()); assert!(enabled); @@ -437,8 +423,7 @@ mod tests { #[allow(deprecated)] { assert_matches!(&rule_commands.commands[1], - Command::SetPushRuleEnabled { scope, kind, rule_id, enabled } => { - assert_eq!(scope, &RuleScope::Global); + Command::SetPushRuleEnabled { kind, rule_id, enabled } => { assert_eq!(kind, &RuleKind::Content); assert_eq!(rule_id, PredefinedContentRuleId::ContainsUserName.as_str()); assert!(enabled); @@ -446,8 +431,7 @@ mod tests { ); assert_matches!(&rule_commands.commands[2], - Command::SetPushRuleEnabled { scope, kind, rule_id, enabled } => { - assert_eq!(scope, &RuleScope::Global); + Command::SetPushRuleEnabled { kind, rule_id, enabled } => { assert_eq!(kind, &RuleKind::Override); assert_eq!(rule_id, PredefinedOverrideRuleId::ContainsDisplayName.as_str()); assert!(enabled); @@ -499,8 +483,7 @@ mod tests { assert_eq!(rule_commands.commands.len(), 2); assert_matches!(&rule_commands.commands[0], - Command::SetPushRuleEnabled { scope, kind, rule_id, enabled } => { - assert_eq!(scope, &RuleScope::Global); + Command::SetPushRuleEnabled { kind, rule_id, enabled } => { assert_eq!(kind, &RuleKind::Override); assert_eq!(rule_id, PredefinedOverrideRuleId::IsRoomMention.as_str()); assert!(enabled); @@ -510,8 +493,7 @@ mod tests { #[allow(deprecated)] { assert_matches!(&rule_commands.commands[1], - Command::SetPushRuleEnabled { scope, kind, rule_id, enabled } => { - assert_eq!(scope, &RuleScope::Global); + Command::SetPushRuleEnabled { kind, rule_id, enabled } => { assert_eq!(kind, &RuleKind::Override); assert_eq!(rule_id, PredefinedOverrideRuleId::RoomNotif.as_str()); assert!(enabled); @@ -550,8 +532,7 @@ mod tests { // and a `SetPushRuleActions` command must have been added assert_eq!(rule_commands.commands.len(), 1); assert_matches!(&rule_commands.commands[0], - Command::SetPushRuleActions { scope, kind, rule_id, actions } => { - assert_eq!(scope, &RuleScope::Global); + Command::SetPushRuleActions { kind, rule_id, actions } => { assert_eq!(kind, &RuleKind::Underride); assert_eq!(rule_id, PredefinedUnderrideRuleId::Message.as_str()); assert_eq!(actions.len(), 2); diff --git a/crates/matrix-sdk/src/notification_settings/rules.rs b/crates/matrix-sdk/src/notification_settings/rules.rs index 9414852585b..353af7b837d 100644 --- a/crates/matrix-sdk/src/notification_settings/rules.rs +++ b/crates/matrix-sdk/src/notification_settings/rules.rs @@ -253,7 +253,7 @@ impl Rules { pub(crate) fn apply(&mut self, commands: RuleCommands) { for command in commands.commands { match command { - Command::DeletePushRule { scope: _, kind, rule_id } => { + Command::DeletePushRule { kind, rule_id } => { _ = self.ruleset.remove(kind, rule_id); } Command::SetRoomPushRule { .. } @@ -263,10 +263,10 @@ impl Rules { _ = self.ruleset.insert(push_rule, None, None); } } - Command::SetPushRuleEnabled { scope: _, kind, rule_id, enabled } => { + Command::SetPushRuleEnabled { kind, rule_id, enabled } => { _ = self.ruleset.set_enabled(kind, rule_id, enabled); } - Command::SetPushRuleActions { scope: _, kind, rule_id, actions } => { + Command::SetPushRuleActions { kind, rule_id, actions } => { _ = self.ruleset.set_actions(kind, rule_id, actions); } } diff --git a/crates/matrix-sdk/src/room/mod.rs b/crates/matrix-sdk/src/room/mod.rs index 5561deee315..9fc87b58755 100644 --- a/crates/matrix-sdk/src/room/mod.rs +++ b/crates/matrix-sdk/src/room/mod.rs @@ -78,7 +78,7 @@ use ruma::{ beacon_info::BeaconInfoEventContent, call::notify::{ApplicationType, CallNotifyEventContent, NotifyType}, direct::DirectEventContent, - marked_unread::MarkedUnreadEventContent, + marked_unread::{MarkedUnreadEventContent, UnstableMarkedUnreadEventContent}, receipt::{Receipt, ReceiptThread, ReceiptType}, room::{ avatar::{self, RoomAvatarEventContent}, @@ -2941,7 +2941,7 @@ impl Room { pub async fn set_unread_flag(&self, unread: bool) -> Result<()> { let user_id = self.client.user_id().ok_or(Error::AuthenticationRequired)?; - let content = MarkedUnreadEventContent::new(unread); + let content = UnstableMarkedUnreadEventContent::from(MarkedUnreadEventContent::new(unread)); let request = set_room_account_data::v3::Request::new( user_id.to_owned(), diff --git a/crates/matrix-sdk/src/sliding_sync/mod.rs b/crates/matrix-sdk/src/sliding_sync/mod.rs index 43258f4f634..322a7563f00 100644 --- a/crates/matrix-sdk/src/sliding_sync/mod.rs +++ b/crates/matrix-sdk/src/sliding_sync/mod.rs @@ -1106,7 +1106,7 @@ mod tests { use matrix_sdk_test::async_test; use ruma::{ api::client::error::ErrorKind, assign, owned_room_id, room_id, serde::Raw, uint, - DeviceKeyAlgorithm, OwnedRoomId, TransactionId, + OwnedRoomId, TransactionId, }; use serde::Deserialize; use serde_json::json; @@ -2689,6 +2689,8 @@ mod tests { #[async_test] #[cfg(feature = "e2e-encryption")] async fn test_process_only_encryption_events() -> Result<()> { + use ruma::OneTimeKeyAlgorithm; + let room = owned_room_id!("!croissant:example.org"); let server = MockServer::start().await; @@ -2705,7 +2707,7 @@ mod tests { extensions: assign!(http::response::Extensions::default(), { e2ee: assign!(http::response::E2EE::default(), { - device_one_time_keys_count: BTreeMap::from([(DeviceKeyAlgorithm::SignedCurve25519, uint!(42))]) + device_one_time_keys_count: BTreeMap::from([(OneTimeKeyAlgorithm::SignedCurve25519, uint!(42))]) }), to_device: Some(assign!(http::response::ToDevice::default(), { next_batch: "to-device-token".to_owned(), diff --git a/crates/matrix-sdk/tests/integration/encryption/verification.rs b/crates/matrix-sdk/tests/integration/encryption/verification.rs index ab7eb336fec..69bc38514f6 100644 --- a/crates/matrix-sdk/tests/integration/encryption/verification.rs +++ b/crates/matrix-sdk/tests/integration/encryption/verification.rs @@ -20,7 +20,7 @@ use ruma::{ encryption::{CrossSigningKey, DeviceKeys}, owned_device_id, owned_user_id, serde::Raw, - user_id, DeviceId, DeviceKeyId, OwnedDeviceId, OwnedUserId, + user_id, CrossSigningKeyId, DeviceId, OwnedDeviceId, OwnedUserId, }; use serde_json::json; use wiremock::{ @@ -239,8 +239,10 @@ fn mock_keys_signature_upload(keys: Arc>) -> impl Fn(&Request) -> Re if let Some(existing_master_key) = keys.master.get_mut(&user) { let mut existing = existing_master_key.deserialize().unwrap(); - let target = - DeviceKeyId::from_parts(ruma::DeviceKeyAlgorithm::Ed25519, key_id.into()); + let target = CrossSigningKeyId::from_parts( + ruma::SigningKeyAlgorithm::Ed25519, + key_id.try_into().unwrap(), + ); if existing.keys.contains_key(&target) { let param: CrossSigningKey = serde_json::from_str(raw_key.get()).unwrap();