Skip to content

Commit abc8a14

Browse files
committed
feat(crypto): Support for new UtdCause for historical messages
1 parent afed926 commit abc8a14

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEncryptedView.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ fun TimelineItemEncryptedView(
4040
UtdCause.UnknownDevice -> {
4141
CommonStrings.common_unable_to_decrypt_insecure_device to CompoundDrawables.ic_compound_block
4242
}
43-
UtdCause.HistoricalMessage -> {
43+
UtdCause.HistoricalMessageAndBackupIsDisabled -> {
4444
CommonStrings.timeline_decryption_failure_historical_event_no_key_backup to CompoundDrawables.ic_compound_block
4545
}
46+
UtdCause.HistoricalMessageAndDeviceIsUnverified -> {
47+
CommonStrings.timeline_decryption_failure_historical_event_unverified_device to CompoundDrawables.ic_compound_block
48+
}
4649
UtdCause.WithheldUnverifiedOrInsecureDevice -> {
4750
CommonStrings.timeline_decryption_failure_withheld_unverified to CompoundDrawables.ic_compound_block
4851
}

libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/item/event/UtdCause.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@ enum class UtdCause {
1515
UnknownDevice,
1616

1717
/**
18-
* Expected utd because this is a device-historical message and
19-
* key storage is not setup or not configured correctly.
18+
* We are missing the keys for this event, but it is a "device-historical" message and
19+
* there is no key storage backup on the server, presumably because the user has turned it off.
2020
*/
21-
HistoricalMessage,
21+
HistoricalMessageAndBackupIsDisabled,
22+
23+
/**
24+
* We are missing the keys for this event, but it is a "device-historical"
25+
* message, and even though a key storage backup does exist, we can't use
26+
* it because our device is unverified.
27+
*/
28+
HistoricalMessageAndDeviceIsUnverified,
2229

2330
/**
2431
* The key was withheld on purpose because your device is insecure and/or the

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/analytics/UtdTracker.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ class UtdTracker(
2727
UtdCause.UNKNOWN_DEVICE -> {
2828
Error.Name.ExpectedSentByInsecureDevice
2929
}
30-
UtdCause.HISTORICAL_MESSAGE -> Error.Name.HistoricalMessage
30+
UtdCause.HISTORICAL_MESSAGE_AND_BACKUP_IS_DISABLED,
31+
UtdCause.HISTORICAL_MESSAGE_AND_DEVICE_IS_UNVERIFIED,
32+
-> Error.Name.HistoricalMessage
3133
UtdCause.WITHHELD_FOR_UNVERIFIED_OR_INSECURE_DEVICE -> Error.Name.RoomKeysWithheldForUnverifiedDevice
3234
UtdCause.WITHHELD_BY_SENDER -> Error.Name.OlmKeysNotSentError
3335
}

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/TimelineEventContentMapper.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ private fun RustUtdCause.map(): UtdCause {
145145
RustUtdCause.VERIFICATION_VIOLATION -> UtdCause.VerificationViolation
146146
RustUtdCause.UNSIGNED_DEVICE -> UtdCause.UnsignedDevice
147147
RustUtdCause.UNKNOWN_DEVICE -> UtdCause.UnknownDevice
148-
RustUtdCause.HISTORICAL_MESSAGE -> UtdCause.HistoricalMessage
148+
RustUtdCause.HISTORICAL_MESSAGE_AND_BACKUP_IS_DISABLED -> UtdCause.HistoricalMessageAndBackupIsDisabled
149+
RustUtdCause.HISTORICAL_MESSAGE_AND_DEVICE_IS_UNVERIFIED -> UtdCause.HistoricalMessageAndDeviceIsUnverified
149150
RustUtdCause.WITHHELD_FOR_UNVERIFIED_OR_INSECURE_DEVICE -> UtdCause.WithheldUnverifiedOrInsecureDevice
150151
RustUtdCause.WITHHELD_BY_SENDER -> UtdCause.WithheldBySender
151152
}

libraries/ui-strings/src/main/res/values/localazy.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ Reason: %1$s."</string>
343343
<string name="test_language_identifier">"en"</string>
344344
<string name="test_untranslated_default_language_identifier">"en"</string>
345345
<string name="timeline_decryption_failure_historical_event_no_key_backup">"Historical messages are not available on this device"</string>
346+
<string name="timeline_decryption_failure_historical_event_unverified_device">"You need to verify this device for access to historical messages"</string>
346347
<string name="timeline_decryption_failure_historical_event_user_not_joined">"You don\'t have access to this message"</string>
347348
<string name="timeline_decryption_failure_unable_to_decrypt">"Unable to decrypt message"</string>
348349
<string name="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."</string>

0 commit comments

Comments
 (0)