commit c357825dc75efef756a2fa08996cd088f1c56784
parent 450e7ee8593b0b00fe95216b7613cf9973877512
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date: Wed, 8 Nov 2023 01:42:45 +0100
refactor(core/e2ee): decryption failure message
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/experiments/EndToEndEncryption.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/experiments/EndToEndEncryption.kt
@@ -318,13 +318,19 @@ class EndToEndEncryption : MessagingRuleFeature(
if (isMe) {
if (conversationParticipants.isEmpty()) return@eachBuffer
val participantId = conversationParticipants.firstOrNull { participantIdHash.contentEquals(hashParticipantId(it, iv)) } ?: return@eachBuffer
- setDecryptedMessage(e2eeInterface.decryptMessage(participantId, ciphertext, iv))
+ setDecryptedMessage(e2eeInterface.decryptMessage(participantId, ciphertext, iv) ?: run {
+ context.log.warn("Failed to decrypt message for participant $participantId")
+ return@eachBuffer
+ })
return@eachBuffer
}
if (!participantIdHash.contentEquals(hashParticipantId(context.database.myUserId, iv))) return@eachBuffer
- setDecryptedMessage(e2eeInterface.decryptMessage(senderId, ciphertext, iv))
+ setDecryptedMessage(e2eeInterface.decryptMessage(senderId, ciphertext, iv)?: run {
+ context.log.warn("Failed to decrypt message")
+ return@eachBuffer
+ })
}
}.onFailure {
context.log.error("Failed to decrypt message id: $clientMessageId", it)