Skip to content

Commit bcac193

Browse files
committed
feat(crypto): Support new expected UTD causes UX + Analytics
1 parent b73884c commit bcac193

File tree

6 files changed

+54
-1
lines changed

6 files changed

+54
-1
lines changed

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

+9
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ fun TimelineItemEncryptedView(
4040
UtdCause.UnknownDevice -> {
4141
CommonStrings.common_unable_to_decrypt_insecure_device to CompoundDrawables.ic_compound_block
4242
}
43+
UtdCause.HistoricalMessage -> {
44+
CommonStrings.timeline_decryption_failure_historical_event_no_key_backup to CompoundDrawables.ic_compound_block
45+
}
46+
UtdCause.WithheldUnverifiedOrInsecureDevice -> {
47+
CommonStrings.timeline_decryption_failure_withheld_unverified to CompoundDrawables.ic_compound_block
48+
}
49+
UtdCause.WithheldBySender -> {
50+
CommonStrings.timeline_decryption_failure_unable_to_decrypt to CompoundDrawables.ic_compound_error
51+
}
4352
else -> {
4453
CommonStrings.common_waiting_for_decryption_key to CompoundDrawables.ic_compound_time
4554
}

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemEncryptedContentProvider.kt

+18
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ open class TimelineItemEncryptedContentProvider : PreviewParameterProvider<Timel
3333
utdCause = UtdCause.UnsignedDevice,
3434
)
3535
),
36+
aTimelineItemEncryptedContent(
37+
data = UnableToDecryptContent.Data.MegolmV1AesSha2(
38+
sessionId = "sessionId",
39+
utdCause = UtdCause.HistoricalMessage,
40+
)
41+
),
42+
aTimelineItemEncryptedContent(
43+
data = UnableToDecryptContent.Data.MegolmV1AesSha2(
44+
sessionId = "sessionId",
45+
utdCause = UtdCause.WithheldUnverifiedOrInsecureDevice,
46+
)
47+
),
48+
aTimelineItemEncryptedContent(
49+
data = UnableToDecryptContent.Data.MegolmV1AesSha2(
50+
sessionId = "sessionId",
51+
utdCause = UtdCause.WithheldBySender,
52+
)
53+
),
3654
aTimelineItemEncryptedContent(
3755
data = UnableToDecryptContent.Data.MegolmV1AesSha2(
3856
sessionId = "sessionId",

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

+18-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,22 @@ enum class UtdCause {
1212
SentBeforeWeJoined,
1313
VerificationViolation,
1414
UnsignedDevice,
15-
UnknownDevice
15+
UnknownDevice,
16+
17+
/**
18+
* Expected utd because this is a device-historical message and
19+
* key storage is not setup or not configured correctly.
20+
*/
21+
HistoricalMessage,
22+
23+
/**
24+
* The key was withheld on purpose because your device is insecure and/or the
25+
* sender trust requirement settings are not met for your device
26+
*/
27+
WithheldUnverifiedOrInsecureDevice,
28+
29+
/**
30+
* Key is withheld by sender
31+
*/
32+
WithheldBySender,
1633
}

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

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class UtdTracker(
2727
UtdCause.UNKNOWN_DEVICE -> {
2828
Error.Name.ExpectedSentByInsecureDevice
2929
}
30+
UtdCause.HISTORICAL_MESSAGE -> Error.Name.HistoricalMessage
31+
UtdCause.WITHHELD_FOR_UNVERIFIED_OR_INSECURE_DEVICE -> Error.Name.RoomKeysWithheldForUnverifiedDevice
32+
UtdCause.WITHHELD_BY_SENDER -> Error.Name.OlmKeysNotSentError
3033
}
3134
val event = Error(
3235
context = null,

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

+3
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ 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
149+
RustUtdCause.WITHHELD_FOR_UNVERIFIED_OR_INSECURE_DEVICE -> UtdCause.WithheldUnverifiedOrInsecureDevice
150+
RustUtdCause.WITHHELD_BY_SENDER -> UtdCause.WithheldBySender
148151
}
149152
}
150153

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

+3
Original file line numberDiff line numberDiff line change
@@ -365,4 +365,7 @@ Reason: %1$s."</string>
365365
<string name="settings_version_number">"Version: %1$s (%2$s)"</string>
366366
<string name="test_language_identifier">"en"</string>
367367
<string name="test_untranslated_default_language_identifier">"en"</string>
368+
<string name="timeline_decryption_failure_historical_event_no_key_backup">"Historical messages are not available on this device"</string>
369+
<string name="timeline_decryption_failure_unable_to_decrypt">"Unable to decrypt message"</string>
370+
<string name="timeline_decryption_failure_withheld_unverified">"This message was blocked either because your device is unverified or because the sender needs to verify your identity."</string>
368371
</resources>

0 commit comments

Comments
 (0)