crypto: The device identity can be our own, so store the identity enum instead.

master
Damir Jelić 2020-08-19 14:43:49 +02:00
parent c2a386b889
commit c3e593d998
2 changed files with 5 additions and 19 deletions

View File

@ -38,7 +38,7 @@ use super::{Account, OlmMachine};
use crate::{ use crate::{
error::SignatureError, error::SignatureError,
store::Result as StoreResult, store::Result as StoreResult,
user_identity::{OwnUserIdentity, UserIdentity}, user_identity::{OwnUserIdentity, UserIdentities},
verification::VerificationMachine, verification::VerificationMachine,
verify_json, ReadOnlyUserDevices, Sas, verify_json, ReadOnlyUserDevices, Sas,
}; };
@ -62,7 +62,7 @@ pub struct Device {
pub(crate) inner: ReadOnlyDevice, pub(crate) inner: ReadOnlyDevice,
pub(crate) verification_machine: VerificationMachine, pub(crate) verification_machine: VerificationMachine,
pub(crate) own_identity: Option<OwnUserIdentity>, pub(crate) own_identity: Option<OwnUserIdentity>,
pub(crate) device_owner_identity: Option<UserIdentity>, pub(crate) device_owner_identity: Option<UserIdentities>,
} }
impl Deref for Device { impl Deref for Device {
@ -103,7 +103,7 @@ pub struct UserDevices {
pub(crate) inner: ReadOnlyUserDevices, pub(crate) inner: ReadOnlyUserDevices,
pub(crate) verification_machine: VerificationMachine, pub(crate) verification_machine: VerificationMachine,
pub(crate) own_identity: Option<OwnUserIdentity>, pub(crate) own_identity: Option<OwnUserIdentity>,
pub(crate) device_owner_identity: Option<UserIdentity>, pub(crate) device_owner_identity: Option<UserIdentities>,
} }
impl UserDevices { impl UserDevices {

View File

@ -1431,14 +1431,7 @@ impl OlmMachine {
.flatten() .flatten()
.map(|i| i.own().cloned()) .map(|i| i.own().cloned())
.flatten(); .flatten();
let device_owner_identity = self let device_owner_identity = self.store.get_user_identity(user_id).await.ok().flatten();
.store
.get_user_identity(user_id)
.await
.ok()
.flatten()
.map(|i| i.other().cloned())
.flatten();
Some(Device { Some(Device {
inner: device, inner: device,
@ -1482,14 +1475,7 @@ impl OlmMachine {
.flatten() .flatten()
.map(|i| i.own().cloned()) .map(|i| i.own().cloned())
.flatten(); .flatten();
let device_owner_identity = self let device_owner_identity = self.store.get_user_identity(user_id).await.ok().flatten();
.store
.get_user_identity(user_id)
.await
.ok()
.flatten()
.map(|i| i.other().cloned())
.flatten();
Ok(UserDevices { Ok(UserDevices {
inner: devices, inner: devices,