From 598e230bd7c44af92e3d96397f9025bb829dcf32 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 16 Dec 2024 10:58:13 +0100 Subject: [PATCH 1/2] feat(crypto): Support for new UtdCause for historical messages --- .../components/event/TimelineItemEncryptedView.kt | 5 ++++- .../matrix/api/timeline/item/event/UtdCause.kt | 13 ++++++++++--- .../libraries/matrix/impl/analytics/UtdTracker.kt | 4 +++- .../item/event/TimelineEventContentMapper.kt | 3 ++- .../ui-strings/src/main/res/values/localazy.xml | 1 + 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEncryptedView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEncryptedView.kt index b91b4ccc17..9ad875377c 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEncryptedView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEncryptedView.kt @@ -40,9 +40,12 @@ fun TimelineItemEncryptedView( UtdCause.UnknownDevice -> { CommonStrings.common_unable_to_decrypt_insecure_device to CompoundDrawables.ic_compound_block } - UtdCause.HistoricalMessage -> { + UtdCause.HistoricalMessageAndBackupIsDisabled -> { CommonStrings.timeline_decryption_failure_historical_event_no_key_backup to CompoundDrawables.ic_compound_block } + UtdCause.HistoricalMessageAndDeviceIsUnverified -> { + CommonStrings.timeline_decryption_failure_historical_event_unverified_device to CompoundDrawables.ic_compound_block + } UtdCause.WithheldUnverifiedOrInsecureDevice -> { CommonStrings.timeline_decryption_failure_withheld_unverified to CompoundDrawables.ic_compound_block } diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/item/event/UtdCause.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/item/event/UtdCause.kt index 51427c6cba..ab39f49bef 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/item/event/UtdCause.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/item/event/UtdCause.kt @@ -15,10 +15,17 @@ enum class UtdCause { UnknownDevice, /** - * Expected utd because this is a device-historical message and - * key storage is not setup or not configured correctly. + * We are missing the keys for this event, but it is a "device-historical" message and + * there is no key storage backup on the server, presumably because the user has turned it off. */ - HistoricalMessage, + HistoricalMessageAndBackupIsDisabled, + + /** + * We are missing the keys for this event, but it is a "device-historical" + * message, and even though a key storage backup does exist, we can't use + * it because our device is unverified. + */ + HistoricalMessageAndDeviceIsUnverified, /** * The key was withheld on purpose because your device is insecure and/or the diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/analytics/UtdTracker.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/analytics/UtdTracker.kt index a8577bbe40..aed1d7a055 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/analytics/UtdTracker.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/analytics/UtdTracker.kt @@ -27,7 +27,9 @@ class UtdTracker( UtdCause.UNKNOWN_DEVICE -> { Error.Name.ExpectedSentByInsecureDevice } - UtdCause.HISTORICAL_MESSAGE -> Error.Name.HistoricalMessage + UtdCause.HISTORICAL_MESSAGE_AND_BACKUP_IS_DISABLED, + UtdCause.HISTORICAL_MESSAGE_AND_DEVICE_IS_UNVERIFIED, + -> Error.Name.HistoricalMessage UtdCause.WITHHELD_FOR_UNVERIFIED_OR_INSECURE_DEVICE -> Error.Name.RoomKeysWithheldForUnverifiedDevice UtdCause.WITHHELD_BY_SENDER -> Error.Name.OlmKeysNotSentError } diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/TimelineEventContentMapper.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/TimelineEventContentMapper.kt index 6e079ffe3f..3d13792eeb 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/TimelineEventContentMapper.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/TimelineEventContentMapper.kt @@ -145,7 +145,8 @@ private fun RustUtdCause.map(): UtdCause { RustUtdCause.VERIFICATION_VIOLATION -> UtdCause.VerificationViolation RustUtdCause.UNSIGNED_DEVICE -> UtdCause.UnsignedDevice RustUtdCause.UNKNOWN_DEVICE -> UtdCause.UnknownDevice - RustUtdCause.HISTORICAL_MESSAGE -> UtdCause.HistoricalMessage + RustUtdCause.HISTORICAL_MESSAGE_AND_BACKUP_IS_DISABLED -> UtdCause.HistoricalMessageAndBackupIsDisabled + RustUtdCause.HISTORICAL_MESSAGE_AND_DEVICE_IS_UNVERIFIED -> UtdCause.HistoricalMessageAndDeviceIsUnverified RustUtdCause.WITHHELD_FOR_UNVERIFIED_OR_INSECURE_DEVICE -> UtdCause.WithheldUnverifiedOrInsecureDevice RustUtdCause.WITHHELD_BY_SENDER -> UtdCause.WithheldBySender } diff --git a/libraries/ui-strings/src/main/res/values/localazy.xml b/libraries/ui-strings/src/main/res/values/localazy.xml index b571a23230..a9771364b7 100644 --- a/libraries/ui-strings/src/main/res/values/localazy.xml +++ b/libraries/ui-strings/src/main/res/values/localazy.xml @@ -343,6 +343,7 @@ Reason: %1$s." "en" "en" "Historical messages are not available on this device" + "You need to verify this device for access to historical messages" "You don\'t have access to this message" "Unable to decrypt message" "This message was blocked either because you did not verify your device or because the sender needs to verify your identity." From a810e139ebc97a9137ff27c2d40239d702410a09 Mon Sep 17 00:00:00 2001 From: ElementBot Date: Wed, 18 Dec 2024 14:35:53 +0000 Subject: [PATCH 2/2] Update screenshots --- ...ne.components.event_TimelineItemEncryptedView_Day_5_en.png | 4 ++-- ...ne.components.event_TimelineItemEncryptedView_Day_6_en.png | 4 ++-- ...ne.components.event_TimelineItemEncryptedView_Day_7_en.png | 4 ++-- ...ne.components.event_TimelineItemEncryptedView_Day_8_en.png | 3 +++ ....components.event_TimelineItemEncryptedView_Night_5_en.png | 4 ++-- ....components.event_TimelineItemEncryptedView_Night_6_en.png | 4 ++-- ....components.event_TimelineItemEncryptedView_Night_7_en.png | 4 ++-- ....components.event_TimelineItemEncryptedView_Night_8_en.png | 3 +++ 8 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_8_en.png create mode 100644 tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_8_en.png diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_5_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_5_en.png index 8f51f4d170..7fec52751b 100644 --- a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_5_en.png +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_5_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aba63b0f223f8480d40e6c9c48ce44a1ae1a8bdcc3d101030b9a0bd5f1e9ebee -size 23773 +oid sha256:dc3b043dcc28ab54ea0564e355b56d39ff79acd5180c9a34f727cb6e113b2611 +size 14473 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_6_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_6_en.png index cff8f7e35f..8f51f4d170 100644 --- a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_6_en.png +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_6_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d5c8494ebb4ceaf3a31b661aec47f8a33afeb7aab1457483b7009099a6b56f86 -size 8960 +oid sha256:aba63b0f223f8480d40e6c9c48ce44a1ae1a8bdcc3d101030b9a0bd5f1e9ebee +size 23773 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_7_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_7_en.png index afa1dd9b61..cff8f7e35f 100644 --- a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_7_en.png +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_7_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fee2af8462597d58274b7168c5cfe1f6d6b0909b048adc0f4fc5b3c12a90b859 -size 8861 +oid sha256:d5c8494ebb4ceaf3a31b661aec47f8a33afeb7aab1457483b7009099a6b56f86 +size 8960 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_8_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_8_en.png new file mode 100644 index 0000000000..afa1dd9b61 --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_8_en.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fee2af8462597d58274b7168c5cfe1f6d6b0909b048adc0f4fc5b3c12a90b859 +size 8861 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_5_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_5_en.png index 8561e18151..3ab5d1cac8 100644 --- a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_5_en.png +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_5_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5d0a687a259fafe830560b762a915e478d680dd7c34a295d72e82fc7c427a815 -size 23403 +oid sha256:c857b7836bc9369cfc950b774479dafcb717d6acc40cf7d8b9b34b99974573db +size 14377 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_6_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_6_en.png index a851ce84e5..8561e18151 100644 --- a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_6_en.png +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_6_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dda55a19381d9f51a270afa644894f909d8c479be0a5e57b977393c9f1253683 -size 8960 +oid sha256:5d0a687a259fafe830560b762a915e478d680dd7c34a295d72e82fc7c427a815 +size 23403 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_7_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_7_en.png index 212726df37..a851ce84e5 100644 --- a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_7_en.png +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_7_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d4f48cd7dc7e2bbf7363d1127e46721c25bb8dd887927dbcffe525f5bb5bae01 -size 8781 +oid sha256:dda55a19381d9f51a270afa644894f909d8c479be0a5e57b977393c9f1253683 +size 8960 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_8_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_8_en.png new file mode 100644 index 0000000000..212726df37 --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_8_en.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4f48cd7dc7e2bbf7363d1127e46721c25bb8dd887927dbcffe525f5bb5bae01 +size 8781