From bdff7aa18f4a24bae0727eba2444b127bee8700e Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Wed, 16 Oct 2024 16:25:51 +0200 Subject: [PATCH] Accept any string as a key for m.direct account data --- Cargo.lock | 37 +++++++------------ Cargo.toml | 4 +- .../src/response_processors.rs | 12 +++--- crates/matrix-sdk-base/src/rooms/mod.rs | 3 +- crates/matrix-sdk-base/src/rooms/normal.rs | 3 +- .../matrix-sdk-base/src/sliding_sync/mod.rs | 28 +++++++------- .../src/store/migration_helpers.rs | 5 ++- crates/matrix-sdk/src/account.rs | 2 +- crates/matrix-sdk/src/encryption/mod.rs | 7 +++- crates/matrix-sdk/src/room/mod.rs | 2 +- crates/matrix-sdk/tests/integration/client.rs | 9 ++++- .../tests/integration/room/common.rs | 3 +- .../tests/integration/room/joined.rs | 35 +++++++++++++++++- .../matrix-sdk/tests/integration/room/left.rs | 12 ++++-- 14 files changed, 104 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5c88e89af..e5e3c2a6ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3725,7 +3725,7 @@ version = "5.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23d385da3c602d29036d2f70beed71c36604df7570be17fed4c5b839616785bf" dependencies = [ - "base64 0.22.1", + "base64 0.21.7", "chrono", "getrandom", "http", @@ -4722,8 +4722,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94984418ae8a5e1160e6c87608141330e9ae26330abf22e3d15416efa96d48a" +source = "git+https://github.com/ruma/ruma.git?rev=35fda7f2f7811156df2e60b223dbf136fc143bc8#35fda7f2f7811156df2e60b223dbf136fc143bc8" dependencies = [ "assign", "js_int", @@ -4740,8 +4739,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "325e054db8d5545c00767d9868356d61e63f2c6cb8b54768346d66696ea4ad48" +source = "git+https://github.com/ruma/ruma.git?rev=35fda7f2f7811156df2e60b223dbf136fc143bc8#35fda7f2f7811156df2e60b223dbf136fc143bc8" dependencies = [ "as_variant", "assign", @@ -4756,7 +4754,7 @@ dependencies = [ "serde", "serde_html_form", "serde_json", - "thiserror 1.0.63", + "thiserror 2.0.3", "url", "web-time", ] @@ -4764,8 +4762,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad71c7f49abaa047ba228339d34f9aaefa4d8b50ebeb8e859d0340cc2138bda8" +source = "git+https://github.com/ruma/ruma.git?rev=35fda7f2f7811156df2e60b223dbf136fc143bc8#35fda7f2f7811156df2e60b223dbf136fc143bc8" dependencies = [ "as_variant", "base64 0.22.1", @@ -4785,7 +4782,7 @@ dependencies = [ "serde", "serde_html_form", "serde_json", - "thiserror 1.0.63", + "thiserror 2.0.3", "time", "tracing", "url", @@ -4797,8 +4794,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be86dccf3504588c1f4dc1bda4ce1f8bbd646fc6dda40c77cc7de6e203e62dad" +source = "git+https://github.com/ruma/ruma.git?rev=35fda7f2f7811156df2e60b223dbf136fc143bc8#35fda7f2f7811156df2e60b223dbf136fc143bc8" dependencies = [ "as_variant", "indexmap 2.6.0", @@ -4813,7 +4809,7 @@ dependencies = [ "ruma-macros", "serde", "serde_json", - "thiserror 1.0.63", + "thiserror 2.0.3", "tracing", "url", "web-time", @@ -4823,8 +4819,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5a09ac22b3352bf7a350514dc9a87e1b56aba04c326ac9ce142740f7218afa" +source = "git+https://github.com/ruma/ruma.git?rev=35fda7f2f7811156df2e60b223dbf136fc143bc8#35fda7f2f7811156df2e60b223dbf136fc143bc8" dependencies = [ "http", "js_int", @@ -4838,8 +4833,7 @@ dependencies = [ [[package]] name = "ruma-html" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7571886b6df90a4ed72e7481a5a39cc2a5b3a4e956e9366ad798e4e2e9fe8005" +source = "git+https://github.com/ruma/ruma.git?rev=35fda7f2f7811156df2e60b223dbf136fc143bc8#35fda7f2f7811156df2e60b223dbf136fc143bc8" dependencies = [ "as_variant", "html5ever", @@ -4851,18 +4845,16 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7f9b534a65698d7db3c08d94bf91de0046fe6c7893a7b360502f65e7011ac4" +source = "git+https://github.com/ruma/ruma.git?rev=35fda7f2f7811156df2e60b223dbf136fc143bc8#35fda7f2f7811156df2e60b223dbf136fc143bc8" dependencies = [ "js_int", - "thiserror 1.0.63", + "thiserror 2.0.3", ] [[package]] name = "ruma-macros" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d57d3cb20e8e758e8f7c5e408ce831d46758003b615100099852e468631934" +source = "git+https://github.com/ruma/ruma.git?rev=35fda7f2f7811156df2e60b223dbf136fc143bc8#35fda7f2f7811156df2e60b223dbf136fc143bc8" dependencies = [ "cfg-if", "once_cell", @@ -4878,8 +4870,7 @@ dependencies = [ [[package]] name = "ruma-push-gateway-api" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfced466fbed6277f74ac3887eeb96c185a09f4323dc3c39bcea04870430fe9a" +source = "git+https://github.com/ruma/ruma.git?rev=35fda7f2f7811156df2e60b223dbf136fc143bc8#35fda7f2f7811156df2e60b223dbf136fc143bc8" dependencies = [ "js_int", "ruma-common", diff --git a/Cargo.toml b/Cargo.toml index 56c356e22d..0b2fb061b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,7 @@ proptest = { version = "1.5.0", default-features = false, features = ["std"] } rand = "0.8.5" reqwest = { version = "0.12.4", default-features = false } rmp-serde = "1.3.0" -ruma = { version = "0.11.1", features = [ +ruma = { git = "https://github.com/ruma/ruma.git", rev = "35fda7f2f7811156df2e60b223dbf136fc143bc8", features = [ "client-api-c", "compat-upload-signatures", "compat-user-id", @@ -70,7 +70,7 @@ ruma = { version = "0.11.1", features = [ "unstable-msc4075", "unstable-msc4140", ] } -ruma-common = "0.14.1" +ruma-common = { git = "https://github.com/ruma/ruma.git", rev = "35fda7f2f7811156df2e60b223dbf136fc143bc8" } serde = "1.0.151" serde_html_form = "0.2.0" serde_json = "1.0.91" diff --git a/crates/matrix-sdk-base/src/response_processors.rs b/crates/matrix-sdk-base/src/response_processors.rs index a6a35a5446..512f2bd2f1 100644 --- a/crates/matrix-sdk-base/src/response_processors.rs +++ b/crates/matrix-sdk-base/src/response_processors.rs @@ -18,9 +18,11 @@ use std::{ }; use ruma::{ - events::{AnyGlobalAccountDataEvent, GlobalAccountDataEventType}, + events::{ + direct::OwnedDirectUserIdentifier, AnyGlobalAccountDataEvent, GlobalAccountDataEventType, + }, serde::Raw, - OwnedUserId, RoomId, + RoomId, }; use tracing::{debug, instrument, trace, warn}; @@ -94,10 +96,10 @@ impl AccountDataProcessor { for event in events { let AnyGlobalAccountDataEvent::Direct(direct_event) = event else { continue }; - let mut new_dms = HashMap::<&RoomId, HashSet>::new(); - for (user_id, rooms) in direct_event.content.iter() { + let mut new_dms = HashMap::<&RoomId, HashSet>::new(); + for (user_identifier, rooms) in direct_event.content.iter() { for room_id in rooms { - new_dms.entry(room_id).or_default().insert(user_id.clone()); + new_dms.entry(room_id).or_default().insert(user_identifier.clone()); } } diff --git a/crates/matrix-sdk-base/src/rooms/mod.rs b/crates/matrix-sdk-base/src/rooms/mod.rs index 9d63e6a840..d86ba3f665 100644 --- a/crates/matrix-sdk-base/src/rooms/mod.rs +++ b/crates/matrix-sdk-base/src/rooms/mod.rs @@ -22,6 +22,7 @@ use ruma::{ events::{ beacon_info::BeaconInfoEventContent, call::member::{CallMemberEventContent, CallMemberStateKey}, + direct::OwnedDirectUserIdentifier, macros::EventContent, room::{ avatar::RoomAvatarEventContent, @@ -128,7 +129,7 @@ pub struct BaseRoomInfo { pub(crate) create: Option>, /// A list of user ids this room is considered as direct message, if this /// room is a DM. - pub(crate) dm_targets: HashSet, + pub(crate) dm_targets: HashSet, /// The `m.room.encryption` event content that enabled E2EE in this room. pub(crate) encryption: Option, /// The guest access policy of this room. diff --git a/crates/matrix-sdk-base/src/rooms/normal.rs b/crates/matrix-sdk-base/src/rooms/normal.rs index 641e6a1228..91367d4267 100644 --- a/crates/matrix-sdk-base/src/rooms/normal.rs +++ b/crates/matrix-sdk-base/src/rooms/normal.rs @@ -33,6 +33,7 @@ use ruma::{ api::client::sync::sync_events::v3::RoomSummary as RumaSummary, events::{ call::member::{CallMemberStateKey, MembershipData}, + direct::OwnedDirectUserIdentifier, ignored_user_list::IgnoredUserListEventContent, receipt::{Receipt, ReceiptThread, ReceiptType}, room::{ @@ -460,7 +461,7 @@ impl Room { /// only be considered as guidance. We leave members in this list to allow /// us to re-find a DM with a user even if they have left, since we may /// want to re-invite them. - pub fn direct_targets(&self) -> HashSet { + pub fn direct_targets(&self) -> HashSet { self.inner.read().base_info.dm_targets.clone() } diff --git a/crates/matrix-sdk-base/src/sliding_sync/mod.rs b/crates/matrix-sdk-base/src/sliding_sync/mod.rs index 19957e1aa0..bdf271b3d5 100644 --- a/crates/matrix-sdk-base/src/sliding_sync/mod.rs +++ b/crates/matrix-sdk-base/src/sliding_sync/mod.rs @@ -911,7 +911,7 @@ mod tests { api::client::sync::sync_events::UnreadNotificationsCount, assign, event_id, events::{ - direct::DirectEventContent, + direct::{DirectEventContent, DirectUserIdentifier, OwnedDirectUserIdentifier}, room::{ avatar::RoomAvatarEventContent, canonical_alias::RoomCanonicalAliasEventContent, @@ -1337,7 +1337,7 @@ mod tests { create_dm(&client, room_id, user_a_id, user_b_id, MembershipState::Join).await; // (Sanity: B is a direct target, and is in Join state) - assert!(direct_targets(&client, room_id).contains(user_b_id)); + assert!(direct_targets(&client, room_id).contains(<&DirectUserIdentifier>::from(user_b_id))); assert_eq!(membership(&client, room_id, user_b_id).await, MembershipState::Join); // When B leaves @@ -1346,7 +1346,7 @@ mod tests { // Then B is still a direct target, and is in Leave state (B is a direct target // because we want to return to our old DM in the UI even if the other // user left, so we can reinvite them. See https://github.com/matrix-org/matrix-rust-sdk/issues/2017) - assert!(direct_targets(&client, room_id).contains(user_b_id)); + assert!(direct_targets(&client, room_id).contains(<&DirectUserIdentifier>::from(user_b_id))); assert_eq!(membership(&client, room_id, user_b_id).await, MembershipState::Leave); } @@ -1362,7 +1362,7 @@ mod tests { create_dm(&client, room_id, user_a_id, user_b_id, MembershipState::Invite).await; // (Sanity: B is a direct target, and is in Invite state) - assert!(direct_targets(&client, room_id).contains(user_b_id)); + assert!(direct_targets(&client, room_id).contains(<&DirectUserIdentifier>::from(user_b_id))); assert_eq!(membership(&client, room_id, user_b_id).await, MembershipState::Invite); // When B declines the invitation (i.e. leaves) @@ -1371,7 +1371,7 @@ mod tests { // Then B is still a direct target, and is in Leave state (B is a direct target // because we want to return to our old DM in the UI even if the other // user left, so we can reinvite them. See https://github.com/matrix-org/matrix-rust-sdk/issues/2017) - assert!(direct_targets(&client, room_id).contains(user_b_id)); + assert!(direct_targets(&client, room_id).contains(<&DirectUserIdentifier>::from(user_b_id))); assert_eq!(membership(&client, room_id, user_b_id).await, MembershipState::Leave); } @@ -1389,7 +1389,7 @@ mod tests { assert_eq!(membership(&client, room_id, user_a_id).await, MembershipState::Join); // (Sanity: B is a direct target, and is in Join state) - assert!(direct_targets(&client, room_id).contains(user_b_id)); + assert!(direct_targets(&client, room_id).contains(<&DirectUserIdentifier>::from(user_b_id))); assert_eq!(membership(&client, room_id, user_b_id).await, MembershipState::Join); let room = client.get_room(room_id).unwrap(); @@ -1413,7 +1413,7 @@ mod tests { assert_eq!(membership(&client, room_id, user_a_id).await, MembershipState::Join); // (Sanity: B is a direct target, and is in Join state) - assert!(direct_targets(&client, room_id).contains(user_b_id)); + assert!(direct_targets(&client, room_id).contains(<&DirectUserIdentifier>::from(user_b_id))); assert_eq!(membership(&client, room_id, user_b_id).await, MembershipState::Invite); let room = client.get_room(room_id).unwrap(); @@ -2558,9 +2558,10 @@ mod tests { let mut room_response = http::response::Room::new(); set_room_joined(&mut room_response, user_a_id); let mut response = response_with_room(room_id_1, room_response); - let mut direct_content = BTreeMap::new(); - direct_content.insert(user_a_id.to_owned(), vec![room_id_1.to_owned()]); - direct_content.insert(user_b_id.to_owned(), vec![room_id_2.to_owned()]); + let mut direct_content: BTreeMap> = + BTreeMap::new(); + direct_content.insert(user_a_id.into(), vec![room_id_1.to_owned()]); + direct_content.insert(user_b_id.into(), vec![room_id_2.to_owned()]); response .extensions .account_data @@ -2671,7 +2672,7 @@ mod tests { member.membership().clone() } - fn direct_targets(client: &BaseClient, room_id: &RoomId) -> HashSet { + fn direct_targets(client: &BaseClient, room_id: &RoomId) -> HashSet { let room = client.get_room(room_id).expect("Room not found!"); room.direct_targets() } @@ -2730,8 +2731,9 @@ mod tests { user_id: OwnedUserId, room_ids: Vec, ) { - let mut direct_content = BTreeMap::new(); - direct_content.insert(user_id, room_ids); + let mut direct_content: BTreeMap> = + BTreeMap::new(); + direct_content.insert(user_id.into(), room_ids); response .extensions .account_data diff --git a/crates/matrix-sdk-base/src/store/migration_helpers.rs b/crates/matrix-sdk-base/src/store/migration_helpers.rs index 76acb86cf4..1943b6578a 100644 --- a/crates/matrix-sdk-base/src/store/migration_helpers.rs +++ b/crates/matrix-sdk-base/src/store/migration_helpers.rs @@ -23,6 +23,7 @@ use std::{ use matrix_sdk_common::deserialized_responses::SyncTimelineEvent; use ruma::{ events::{ + direct::OwnedDirectUserIdentifier, room::{ avatar::RoomAvatarEventContent, canonical_alias::RoomCanonicalAliasEventContent, @@ -37,7 +38,7 @@ use ruma::{ }, EmptyStateKey, EventContent, RedactContent, StateEventContent, StateEventType, }, - OwnedRoomId, OwnedUserId, RoomId, + OwnedRoomId, RoomId, }; use serde::{Deserialize, Serialize}; @@ -155,7 +156,7 @@ fn encryption_state_default() -> bool { struct BaseRoomInfoV1 { avatar: Option>, canonical_alias: Option>, - dm_targets: HashSet, + dm_targets: HashSet, encryption: Option, guest_access: Option>, history_visibility: Option>, diff --git a/crates/matrix-sdk/src/account.rs b/crates/matrix-sdk/src/account.rs index 2e08bb6415..b077d61064 100644 --- a/crates/matrix-sdk/src/account.rs +++ b/crates/matrix-sdk/src/account.rs @@ -861,7 +861,7 @@ impl Account { }; for user_id in user_ids { - content.entry(user_id.to_owned()).or_default().push(room_id.to_owned()); + content.entry(user_id.into()).or_default().push(room_id.to_owned()); } // TODO: We should probably save the fact that we need to send this out diff --git a/crates/matrix-sdk/src/encryption/mod.rs b/crates/matrix-sdk/src/encryption/mod.rs index f8c7909940..9a4130e4ff 100644 --- a/crates/matrix-sdk/src/encryption/mod.rs +++ b/crates/matrix-sdk/src/encryption/mod.rs @@ -50,7 +50,10 @@ use ruma::{ uiaa::{AuthData, UiaaInfo}, }, assign, - events::room::{MediaSource, ThumbnailInfo}, + events::{ + direct::DirectUserIdentifier, + room::{MediaSource, ThumbnailInfo}, + }, DeviceId, OwnedDeviceId, OwnedUserId, TransactionId, UserId, }; use serde::Deserialize; @@ -605,7 +608,7 @@ impl Client { // Find the room we share with the `user_id` and only with `user_id` let room = rooms.into_iter().find(|r| { let targets = r.direct_targets(); - targets.len() == 1 && targets.contains(user_id) + targets.len() == 1 && targets.contains(<&DirectUserIdentifier>::from(user_id)) }); trace!(?room, "Found room"); diff --git a/crates/matrix-sdk/src/room/mod.rs b/crates/matrix-sdk/src/room/mod.rs index fcafbca63b..8b378be0fe 100644 --- a/crates/matrix-sdk/src/room/mod.rs +++ b/crates/matrix-sdk/src/room/mod.rs @@ -1224,7 +1224,7 @@ impl Room { room_members.retain(|member| member.user_id() != self.own_user_id()); for member in room_members { - let entry = content.entry(member.user_id().to_owned()).or_default(); + let entry = content.entry(member.user_id().into()).or_default(); if !entry.iter().any(|room_id| room_id == this_room_id) { entry.push(this_room_id.to_owned()); } diff --git a/crates/matrix-sdk/tests/integration/client.rs b/crates/matrix-sdk/tests/integration/client.rs index a8d7a9e111..87af161f38 100644 --- a/crates/matrix-sdk/tests/integration/client.rs +++ b/crates/matrix-sdk/tests/integration/client.rs @@ -35,7 +35,10 @@ use ruma::{ assign, device_id, directory::Filter, event_id, - events::{direct::DirectEventContent, AnyInitialStateEvent}, + events::{ + direct::{DirectEventContent, DirectUserIdentifier}, + AnyInitialStateEvent, + }, room_id, serde::Raw, user_id, OwnedUserId, @@ -496,7 +499,9 @@ async fn test_marking_room_as_dm() { "The body of the PUT /account_data request should be a valid DirectEventContent", ); - let bob_entry = content.get(bob).expect("We should have bob in the direct event content"); + let bob_entry = content + .get(<&DirectUserIdentifier>::from(bob)) + .expect("We should have bob in the direct event content"); assert_eq!(content.len(), 2, "We should have entries for bob and foo"); assert_eq!(bob_entry.len(), 3, "Bob should have 3 direct rooms"); diff --git a/crates/matrix-sdk/tests/integration/room/common.rs b/crates/matrix-sdk/tests/integration/room/common.rs index f525f49743..3021a114a8 100644 --- a/crates/matrix-sdk/tests/integration/room/common.rs +++ b/crates/matrix-sdk/tests/integration/room/common.rs @@ -11,6 +11,7 @@ use matrix_sdk_test::{ use ruma::{ event_id, events::{ + direct::DirectUserIdentifier, room::{ avatar::{self, RoomAvatarEventContent}, member::MembershipState, @@ -830,7 +831,7 @@ async fn test_is_direct() { // The room is direct now. let direct_targets = room.direct_targets(); assert_eq!(direct_targets.len(), 1); - assert!(direct_targets.contains(*BOB)); + assert!(direct_targets.contains(<&DirectUserIdentifier>::from(*BOB))); assert!(room.is_direct().await.unwrap()); // Unset the room as direct. diff --git a/crates/matrix-sdk/tests/integration/room/joined.rs b/crates/matrix-sdk/tests/integration/room/joined.rs index 322b026948..fa0b3f66af 100644 --- a/crates/matrix-sdk/tests/integration/room/joined.rs +++ b/crates/matrix-sdk/tests/integration/room/joined.rs @@ -22,13 +22,14 @@ use ruma::{ api::client::{membership::Invite3pidInit, receipt::create_receipt::v3::ReceiptType}, assign, event_id, events::{ + direct::DirectUserIdentifier, receipt::ReceiptThread, room::message::{RoomMessageEventContent, RoomMessageEventContentWithoutRelation}, TimelineEventType, }, int, mxc_uri, owned_event_id, room_id, thirdparty, user_id, OwnedUserId, TransactionId, }; -use serde_json::{json, Value}; +use serde_json::{from_value, json, Value}; use wiremock::{ matchers::{body_json, body_partial_json, header, method, path_regex}, Mock, ResponseTemplate, @@ -631,6 +632,38 @@ async fn test_reset_power_levels() { room.reset_power_levels().await.unwrap(); } +#[async_test] +async fn test_is_direct_invite_by_3pid() { + let (client, server) = logged_in_client_with_server().await; + + let mut sync_builder = SyncResponseBuilder::new(); + sync_builder.add_joined_room(JoinedRoomBuilder::default()); + let data = json!({ + "content": { + "invited@localhost.com": [*DEFAULT_TEST_ROOM_ID], + }, + "event_id": "$757957878228ekrDs:localhost", + "origin_server_ts": 17195787, + "sender": "@example:localhost", + "state_key": "", + "type": "m.direct", + "unsigned": { + "age": 139298 + } + }); + sync_builder.add_global_account_data_bulk(vec![from_value(data).unwrap()]); + + mock_sync(&server, sync_builder.build_json_sync_response(), None).await; + mock_encryption_state(&server, false).await; + + let sync_settings = SyncSettings::new().timeout(Duration::from_millis(3000)); + let _response = client.sync_once(sync_settings).await.unwrap(); + + let room = client.get_room(&DEFAULT_TEST_ROOM_ID).unwrap(); + assert!(room.is_direct().await.unwrap()); + assert!(room.direct_targets().contains(<&DirectUserIdentifier>::from("invited@localhost.com"))); +} + #[async_test] async fn test_call_notifications_ring_for_dms() { let (client, server) = logged_in_client_with_server().await; diff --git a/crates/matrix-sdk/tests/integration/room/left.rs b/crates/matrix-sdk/tests/integration/room/left.rs index f2de95649b..dcfe89ef16 100644 --- a/crates/matrix-sdk/tests/integration/room/left.rs +++ b/crates/matrix-sdk/tests/integration/room/left.rs @@ -7,7 +7,10 @@ use matrix_sdk_test::{ async_test, test_json, GlobalAccountDataTestEvent, LeftRoomBuilder, SyncResponseBuilder, DEFAULT_TEST_ROOM_ID, }; -use ruma::{events::direct::DirectEventContent, user_id, OwnedRoomOrAliasId}; +use ruma::{ + events::direct::{DirectEventContent, DirectUserIdentifier, OwnedDirectUserIdentifier}, + user_id, OwnedRoomOrAliasId, +}; use serde_json::json; use wiremock::{ matchers::{header, method, path, path_regex}, @@ -70,7 +73,7 @@ async fn test_forget_direct_room() { let room = client.get_room(&DEFAULT_TEST_ROOM_ID).unwrap(); assert_eq!(room.state(), RoomState::Left); assert!(room.is_direct().await.unwrap()); - assert!(room.direct_targets().contains(invited_user_id)); + assert!(room.direct_targets().contains(<&DirectUserIdentifier>::from(invited_user_id))); let direct_account_data = client .account() @@ -80,7 +83,10 @@ async fn test_forget_direct_room() { .expect("no m.direct account data") .deserialize() .expect("failed to deserialize m.direct account data"); - assert_matches!(direct_account_data.get(invited_user_id), Some(invited_user_dms)); + assert_matches!( + direct_account_data.get(<&DirectUserIdentifier>::from(invited_user_id)), + Some(invited_user_dms) + ); assert_eq!(invited_user_dms, &[DEFAULT_TEST_ROOM_ID.to_owned()]); Mock::given(method("POST"))