diff --git a/matrix_sdk_crypto/src/identities/device.rs b/matrix_sdk_crypto/src/identities/device.rs index 63d9853c..bec4e995 100644 --- a/matrix_sdk_crypto/src/identities/device.rs +++ b/matrix_sdk_crypto/src/identities/device.rs @@ -55,7 +55,7 @@ use crate::{OlmMachine, ReadOnlyAccount}; #[derive(Clone, Serialize, Deserialize)] pub struct ReadOnlyDevice { user_id: Arc, - device_id: Arc, + device_id: Arc, algorithms: Arc<[EventEncryptionAlgorithm]>, keys: Arc>, pub(crate) signatures: Arc>>, @@ -301,7 +301,7 @@ impl ReadOnlyDevice { ) -> Self { Self { user_id: Arc::new(user_id), - device_id: Arc::new(device_id), + device_id: device_id.into(), display_name: Arc::new(display_name), trust_state: Arc::new(Atomic::new(trust_state)), signatures: Arc::new(signatures), @@ -546,7 +546,7 @@ impl TryFrom<&DeviceKeys> for ReadOnlyDevice { fn try_from(device_keys: &DeviceKeys) -> Result { let device = Self { user_id: Arc::new(device_keys.user_id.clone()), - device_id: Arc::new(device_keys.device_id.clone()), + device_id: device_keys.device_id.clone().into(), algorithms: device_keys.algorithms.as_slice().into(), signatures: Arc::new(device_keys.signatures.clone()), keys: Arc::new(device_keys.keys.clone()), diff --git a/matrix_sdk_crypto/src/identities/manager.rs b/matrix_sdk_crypto/src/identities/manager.rs index 734591f8..37629fda 100644 --- a/matrix_sdk_crypto/src/identities/manager.rs +++ b/matrix_sdk_crypto/src/identities/manager.rs @@ -23,7 +23,7 @@ use matrix_sdk_common::{ api::r0::keys::get_keys::Response as KeysQueryResponse, encryption::DeviceKeys, executor::spawn, - identifiers::{DeviceIdBox, UserId}, + identifiers::{DeviceId, DeviceIdBox, UserId}, }; use tracing::{trace, warn}; @@ -46,14 +46,14 @@ enum DeviceChange { #[derive(Debug, Clone)] pub(crate) struct IdentityManager { user_id: Arc, - device_id: Arc, + device_id: Arc, store: Store, } impl IdentityManager { const MAX_KEY_QUERY_USERS: usize = 250; - pub fn new(user_id: Arc, device_id: Arc, store: Store) -> Self { + pub fn new(user_id: Arc, device_id: Arc, store: Store) -> Self { IdentityManager { user_id, device_id, store } } @@ -134,7 +134,7 @@ impl IdentityManager { async fn update_user_devices( store: Store, own_user_id: Arc, - own_device_id: Arc, + own_device_id: Arc, user_id: UserId, device_map: BTreeMap, ) -> StoreResult { @@ -144,7 +144,7 @@ impl IdentityManager { let tasks = device_map.into_iter().filter_map(|(device_id, device_keys)| { // We don't need our own device in the device store. - if user_id == *own_user_id && device_id == *own_device_id { + if user_id == *own_user_id && *device_id == *own_device_id { None } else if user_id != device_keys.user_id || device_id != device_keys.device_id { warn!( @@ -431,7 +431,7 @@ pub(crate) mod test { Arc::new(Box::new(MemoryStore::new())), verification, ); - IdentityManager::new(user_id, Arc::new(device_id()), store) + IdentityManager::new(user_id, device_id().into(), store) } pub(crate) fn other_key_query() -> KeyQueryResponse { diff --git a/matrix_sdk_crypto/src/key_request.rs b/matrix_sdk_crypto/src/key_request.rs index f1dbb43a..ab359e52 100644 --- a/matrix_sdk_crypto/src/key_request.rs +++ b/matrix_sdk_crypto/src/key_request.rs @@ -125,7 +125,7 @@ impl WaitQueue { #[derive(Debug, Clone)] pub(crate) struct KeyRequestMachine { user_id: Arc, - device_id: Arc, + device_id: Arc, store: Store, outbound_group_sessions: GroupSessionCache, outgoing_to_device_requests: Arc>, @@ -210,7 +210,7 @@ fn wrap_key_request_content( impl KeyRequestMachine { pub fn new( user_id: Arc, - device_id: Arc, + device_id: Arc, store: Store, outbound_group_sessions: GroupSessionCache, users_for_key_claim: Arc>>, @@ -854,7 +854,7 @@ mod test { KeyRequestMachine::new( user_id, - Arc::new(bob_device_id()), + bob_device_id().into(), store, session_cache, Arc::new(DashMap::new()), @@ -862,7 +862,7 @@ mod test { } async fn get_machine() -> KeyRequestMachine { - let user_id = Arc::new(alice_id()); + let user_id: Arc = alice_id().into(); let account = ReadOnlyAccount::new(&user_id, &alice_device_id()); let device = ReadOnlyDevice::from_account(&account).await; let store: Arc> = Arc::new(Box::new(MemoryStore::new())); @@ -874,7 +874,7 @@ mod test { KeyRequestMachine::new( user_id, - Arc::new(alice_device_id()), + alice_device_id().into(), store, session_cache, Arc::new(DashMap::new()), diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index fc6734d2..6d969ff2 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -71,7 +71,7 @@ pub struct OlmMachine { /// The unique user id that owns this account. user_id: Arc, /// The unique device id of the device that holds this account. - device_id: Arc>, + device_id: Arc, /// Our underlying Olm Account holding our identity keys. account: Account, /// The private part of our cross signing identity. @@ -149,7 +149,7 @@ impl OlmMachine { VerificationMachine::new(account.clone(), user_identity.clone(), store.clone()); let store = Store::new(user_id.clone(), user_identity.clone(), store, verification_machine.clone()); - let device_id: Arc = Arc::new(device_id); + let device_id: Arc = device_id.into(); let users_for_key_claim = Arc::new(DashMap::new()); let account = Account { inner: account, store: store.clone() }; diff --git a/matrix_sdk_crypto/src/olm/account.rs b/matrix_sdk_crypto/src/olm/account.rs index 2208a621..c0416909 100644 --- a/matrix_sdk_crypto/src/olm/account.rs +++ b/matrix_sdk_crypto/src/olm/account.rs @@ -431,7 +431,7 @@ impl Account { #[derive(Clone)] pub struct ReadOnlyAccount { pub(crate) user_id: Arc, - pub(crate) device_id: Arc>, + pub(crate) device_id: Arc, inner: Arc>, pub(crate) identity_keys: Arc, shared: Arc, @@ -502,7 +502,7 @@ impl ReadOnlyAccount { Self { user_id: Arc::new(user_id.to_owned()), - device_id: Arc::new(device_id.into()), + device_id: device_id.to_owned().into(), inner: Arc::new(Mutex::new(account)), identity_keys: Arc::new(identity_keys), shared: Arc::new(AtomicBool::new(false)), @@ -676,7 +676,7 @@ impl ReadOnlyAccount { Ok(Self { user_id: Arc::new(pickle.user_id), - device_id: Arc::new(pickle.device_id), + device_id: pickle.device_id.into(), inner: Arc::new(Mutex::new(account)), identity_keys: Arc::new(identity_keys), shared: Arc::new(AtomicBool::from(pickle.shared)), @@ -700,7 +700,7 @@ impl ReadOnlyAccount { DeviceKeys::new( (*self.user_id).clone(), - (*self.device_id).clone(), + (*self.device_id).to_owned(), Self::ALGORITHMS.iter().map(|a| (&**a).clone()).collect(), keys, BTreeMap::new(), diff --git a/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs b/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs index 30d97d20..efca136a 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs @@ -118,7 +118,7 @@ impl EncryptionSettings { #[derive(Clone)] pub struct OutboundGroupSession { inner: Arc>, - device_id: Arc, + device_id: Arc, account_identity_keys: Arc, session_id: Arc, room_id: Arc, @@ -148,7 +148,7 @@ impl OutboundGroupSession { /// * `settings` - Settings determining the algorithm and rotation period of /// the outbound group session. pub fn new( - device_id: Arc, + device_id: Arc, identity_keys: Arc, room_id: &RoomId, settings: EncryptionSettings, @@ -450,7 +450,7 @@ impl OutboundGroupSession { /// * `pickle_mode` - The mode that was used to pickle the session, either /// an unencrypted mode or an encrypted using passphrase. pub fn from_pickle( - device_id: Arc, + device_id: Arc, identity_keys: Arc, pickle: PickledOutboundGroupSession, pickling_mode: PicklingMode, diff --git a/matrix_sdk_crypto/src/olm/session.rs b/matrix_sdk_crypto/src/olm/session.rs index d89c2841..c51d389e 100644 --- a/matrix_sdk_crypto/src/olm/session.rs +++ b/matrix_sdk_crypto/src/olm/session.rs @@ -45,7 +45,7 @@ use crate::{ #[derive(Clone)] pub struct Session { pub(crate) user_id: Arc, - pub(crate) device_id: Arc>, + pub(crate) device_id: Arc, pub(crate) our_identity_keys: Arc, pub(crate) inner: Arc>, pub(crate) session_id: Arc, @@ -214,7 +214,7 @@ impl Session { /// an unencrypted mode or an encrypted using passphrase. pub fn from_pickle( user_id: Arc, - device_id: Arc>, + device_id: Arc, our_identity_keys: Arc, pickle: PickledSession, pickle_mode: PicklingMode, diff --git a/matrix_sdk_crypto/src/session_manager/sessions.rs b/matrix_sdk_crypto/src/session_manager/sessions.rs index 51b52846..909e8f37 100644 --- a/matrix_sdk_crypto/src/session_manager/sessions.rs +++ b/matrix_sdk_crypto/src/session_manager/sessions.rs @@ -339,7 +339,7 @@ mod test { VerificationMachine::new(account.clone(), identity.clone(), store.clone()); let user_id = Arc::new(user_id); - let device_id = Arc::new(device_id); + let device_id = device_id.into(); let store = Store::new(user_id.clone(), identity, store, verification); diff --git a/matrix_sdk_crypto/src/store/sled.rs b/matrix_sdk_crypto/src/store/sled.rs index 2a40b083..d1dc9920 100644 --- a/matrix_sdk_crypto/src/store/sled.rs +++ b/matrix_sdk_crypto/src/store/sled.rs @@ -117,7 +117,7 @@ impl EncodeKey for (&str, &str, &str) { #[derive(Clone, Debug)] pub struct AccountInfo { user_id: Arc, - device_id: Arc, + device_id: Arc, identity_keys: Arc, }