From 1e72131e7fe2abbd7dc55cb2fd04c64ec47a579c Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Sun, 1 Dec 2024 22:19:52 +0000 Subject: [PATCH] feat(ui) Add `UnableToDecryptInfo::user_trusts_own_identity` --- crates/matrix-sdk-ui/src/unable_to_decrypt_hook.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/matrix-sdk-ui/src/unable_to_decrypt_hook.rs b/crates/matrix-sdk-ui/src/unable_to_decrypt_hook.rs index 6e89f00ce..ff40371b8 100644 --- a/crates/matrix-sdk-ui/src/unable_to_decrypt_hook.rs +++ b/crates/matrix-sdk-ui/src/unable_to_decrypt_hook.rs @@ -68,6 +68,9 @@ pub struct UnableToDecryptInfo { /// the time our device was created. If negative, this event was sent /// *before* our device was created. pub event_local_age_millis: i64, + + /// Whether the user had verified their own identity at the point they received the UTD event. + pub user_trusts_own_identity: bool, } /// Data about a UTD event which we are waiting to report to the parent hook. @@ -236,12 +239,23 @@ impl UtdHookManager { let event_local_age_millis = i64::from(event_timestamp.get()).saturating_sub_unsigned( self.client.encryption().device_creation_timestamp().await.get().into(), ); + let user_trusts_own_identity = if let Some(own_user_id) = self.client.user_id() { + if let Ok(Some(own_id)) = self.client.encryption().get_user_identity(own_user_id).await + { + own_id.is_verified() + } else { + false + } + } else { + false + }; let info = UnableToDecryptInfo { event_id: event_id.to_owned(), time_to_decrypt: None, cause, event_local_age_millis, + user_trusts_own_identity, }; let Some(max_delay) = self.max_delay else {