From a12292f1b2f2973fbc7097e979e1d2ad6aa5d240 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 16 Dec 2024 11:34:46 +0100 Subject: [PATCH] feat(crypto): Support for new UtdCause for historical messages --- .../Resources/Localizations/en.lproj/Localizable.strings | 1 + ElementX/Sources/Generated/Strings.swift | 2 ++ .../View/TimelineItemViews/EncryptedRoomTimelineView.swift | 3 ++- .../Items/Other/EncryptedRoomTimelineItem.swift | 3 ++- .../Timeline/TimelineItems/RoomTimelineItemFactory.swift | 7 +++++-- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ElementX/Resources/Localizations/en.lproj/Localizable.strings b/ElementX/Resources/Localizations/en.lproj/Localizable.strings index 9b58c30ea2..adbfd58391 100644 --- a/ElementX/Resources/Localizations/en.lproj/Localizable.strings +++ b/ElementX/Resources/Localizations/en.lproj/Localizable.strings @@ -1035,6 +1035,7 @@ "test_language_identifier" = "en"; "test_untranslated_default_language_identifier" = "en"; "timeline_decryption_failure_historical_event_no_key_backup" = "Historical messages are not available on this device"; +"timeline_decryption_failure_historical_event_unverified_device" = "You need to verify this device for access to historical messages"; "timeline_decryption_failure_historical_event_user_not_joined" = "You don't have access to this message"; "timeline_decryption_failure_unable_to_decrypt" = "Unable to decrypt message"; "timeline_decryption_failure_withheld_unverified" = "This message was blocked either because you did not verify your device or because the sender needs to verify your identity."; diff --git a/ElementX/Sources/Generated/Strings.swift b/ElementX/Sources/Generated/Strings.swift index 6ef48306d0..046a5b8963 100644 --- a/ElementX/Sources/Generated/Strings.swift +++ b/ElementX/Sources/Generated/Strings.swift @@ -2592,6 +2592,8 @@ internal enum L10n { internal static var testUntranslatedDefaultLanguageIdentifier: String { return L10n.tr("Localizable", "test_untranslated_default_language_identifier") } /// Historical messages are not available on this device internal static var timelineDecryptionFailureHistoricalEventNoKeyBackup: String { return L10n.tr("Localizable", "timeline_decryption_failure_historical_event_no_key_backup") } + /// You need to verify this device for access to historical messages + internal static var timelineDecryptionFailureHistoricalEventUnverifiedDevice: String { return L10n.tr("Localizable", "timeline_decryption_failure_historical_event_unverified_device") } /// You don't have access to this message internal static var timelineDecryptionFailureHistoricalEventUserNotJoined: String { return L10n.tr("Localizable", "timeline_decryption_failure_historical_event_user_not_joined") } /// Unable to decrypt message diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/EncryptedRoomTimelineView.swift b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/EncryptedRoomTimelineView.swift index 5324b60d27..6605726522 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/EncryptedRoomTimelineView.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/EncryptedRoomTimelineView.swift @@ -18,7 +18,8 @@ struct EncryptedRoomTimelineView: View { case .unknown: return \.time case .sentBeforeWeJoined, - .historicalMessage, + .historicalMessageAndBackupDisabled, + .historicalMessageAndDeviceIsUnverified, .verificationViolation, .insecureDevice, .witheldBySender, diff --git a/ElementX/Sources/Services/Timeline/TimelineItems/Items/Other/EncryptedRoomTimelineItem.swift b/ElementX/Sources/Services/Timeline/TimelineItems/Items/Other/EncryptedRoomTimelineItem.swift index 7baf86a755..270ecff92f 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItems/Items/Other/EncryptedRoomTimelineItem.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItems/Items/Other/EncryptedRoomTimelineItem.swift @@ -19,7 +19,8 @@ struct EncryptedRoomTimelineItem: EventBasedTimelineItemProtocol, Equatable { case verificationViolation case insecureDevice case unknown - case historicalMessage + case historicalMessageAndBackupDisabled + case historicalMessageAndDeviceIsUnverified case witheldBySender case withheldForUnverifiedOrInsecureDevice } diff --git a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift index b512faad3b..a8b88d3928 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift @@ -153,9 +153,12 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol { case .sentBeforeWeJoined: encryptionType = .megolmV1AesSha2(sessionID: sessionID, cause: .sentBeforeWeJoined) errorLabel = L10n.commonUnableToDecryptNoAccess - case .historicalMessageAndBackupIsDisabled, .historicalMessageAndDeviceIsUnverified: - encryptionType = .megolmV1AesSha2(sessionID: sessionID, cause: .historicalMessage) + case .historicalMessageAndBackupIsDisabled: + encryptionType = .megolmV1AesSha2(sessionID: sessionID, cause: .historicalMessageAndBackupDisabled) errorLabel = L10n.timelineDecryptionFailureHistoricalEventNoKeyBackup + case .historicalMessageAndDeviceIsUnverified: + encryptionType = .megolmV1AesSha2(sessionID: sessionID, cause: .historicalMessageAndDeviceIsUnverified) + errorLabel = L10n.timelineDecryptionFailureHistoricalEventUnverifiedDevice case .withheldForUnverifiedOrInsecureDevice: encryptionType = .megolmV1AesSha2(sessionID: sessionID, cause: .withheldForUnverifiedOrInsecureDevice) errorLabel = L10n.timelineDecryptionFailureWithheldUnverified