diff --git a/crates/matrix-sdk-ui/src/timeline/event_handler.rs b/crates/matrix-sdk-ui/src/timeline/event_handler.rs index 210fec68e39..45dedc98088 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_handler.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_handler.rs @@ -416,11 +416,14 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { } }, - TimelineEventKind::UnableToDecrypt { content, .. } => { + TimelineEventKind::UnableToDecrypt { content, unable_to_decrypt_info } => { // TODO: Handle replacements if the replaced event is also UTD let raw_event = self.ctx.flow.raw_event(); let cause = UtdCause::determine(raw_event); - self.add_item(TimelineItemContent::unable_to_decrypt(content, cause), None); + self.add_item( + TimelineItemContent::unable_to_decrypt(content, unable_to_decrypt_info, cause), + None, + ); // Let the hook know that we ran into an unable-to-decrypt that is added to the // timeline. diff --git a/crates/matrix-sdk-ui/src/timeline/event_item/content/mod.rs b/crates/matrix-sdk-ui/src/timeline/event_item/content/mod.rs index 7df383701b6..c6bb16fafce 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_item/content/mod.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_item/content/mod.rs @@ -17,7 +17,10 @@ use std::sync::Arc; use as_variant::as_variant; use imbl::Vector; use matrix_sdk::crypto::types::events::UtdCause; -use matrix_sdk_base::latest_event::{is_suitable_for_latest_event, PossibleLatestEvent}; +use matrix_sdk_base::{ + deserialized_responses::UnableToDecryptInfo, + latest_event::{is_suitable_for_latest_event, PossibleLatestEvent}, +}; use ruma::{ events::{ call::{invite::SyncCallInviteEvent, notify::SyncCallNotifyEvent}, @@ -329,8 +332,16 @@ impl TimelineItemContent { } } - pub(crate) fn unable_to_decrypt(content: RoomEncryptedEventContent, cause: UtdCause) -> Self { - Self::UnableToDecrypt(EncryptedMessage::from_content(content, cause)) + pub(crate) fn unable_to_decrypt( + content: RoomEncryptedEventContent, + unable_to_decrypt_info: UnableToDecryptInfo, + cause: UtdCause, + ) -> Self { + Self::UnableToDecrypt(EncryptedMessage::from_content( + content, + unable_to_decrypt_info, + cause, + )) } pub(crate) fn room_member( @@ -437,8 +448,12 @@ pub enum EncryptedMessage { device_id: OwnedDeviceId, /// The ID of the session used to encrypt the message. + /// TODO: remove? it's the same as unable_to_decrypt_info.session_id session_id: String, + /// Information on the decryption failure from the crypto crate. + unable_to_decrypt_info: UnableToDecryptInfo, + /// What we know about what caused this UTD. E.g. was this event sent /// when we were not a member of this room? cause: UtdCause, @@ -448,7 +463,11 @@ pub enum EncryptedMessage { } impl EncryptedMessage { - fn from_content(content: RoomEncryptedEventContent, cause: UtdCause) -> Self { + fn from_content( + content: RoomEncryptedEventContent, + unable_to_decrypt_info: UnableToDecryptInfo, + cause: UtdCause, + ) -> Self { match content.scheme { EncryptedEventScheme::OlmV1Curve25519AesSha2(s) => { Self::OlmV1Curve25519AesSha2 { sender_key: s.sender_key } @@ -457,7 +476,13 @@ impl EncryptedMessage { EncryptedEventScheme::MegolmV1AesSha2(s) => { let MegolmV1AesSha2Content { sender_key, device_id, session_id, .. } = s; - Self::MegolmV1AesSha2 { sender_key, device_id, session_id, cause } + Self::MegolmV1AesSha2 { + sender_key, + device_id, + session_id, + unable_to_decrypt_info, + cause, + } } _ => Self::Unknown, }