fix(core/e2ee): failed to send to unencrypted conversations

- auto enable feature after a shared key exchange
This commit is contained in:
rhunk
2023-10-27 01:56:54 +02:00
parent 095020d8f8
commit bf9444dfb6

View File

@ -130,6 +130,7 @@ class EndToEndEncryption : MessagingRuleFeature(
context.longToast("Failed to accept public key") context.longToast("Failed to accept public key")
return@warnKeyOverwrite return@warnKeyOverwrite
} }
setState(conversationId, true)
context.longToast("Public key successfully accepted") context.longToast("Public key successfully accepted")
sendCustomMessage(conversationId, RESPONSE_SK_MESSAGE_ID) { sendCustomMessage(conversationId, RESPONSE_SK_MESSAGE_ID) {
@ -150,6 +151,7 @@ class EndToEndEncryption : MessagingRuleFeature(
context.longToast("Failed to accept secret") context.longToast("Failed to accept secret")
return@warnKeyOverwrite return@warnKeyOverwrite
} }
setState(conversationId, true)
context.longToast("Done! You can now exchange encrypted messages with this friend.") context.longToast("Done! You can now exchange encrypted messages with this friend.")
} }
} }
@ -411,7 +413,7 @@ class EndToEndEncryption : MessagingRuleFeature(
conversationIds.add(SnapUUID.fromBytes(getByteArray(1, 1, 1) ?: return@eachBuffer)) conversationIds.add(SnapUUID.fromBytes(getByteArray(1, 1, 1) ?: return@eachBuffer))
} }
if (conversationIds.any { !getState(it.toString()) }) { if (conversationIds.any { !getState(it.toString()) || getE2EParticipants(it.toString()).isEmpty() }) {
context.log.debug("Skipping encryption for conversation ids: ${conversationIds.joinToString(", ")}") context.log.debug("Skipping encryption for conversation ids: ${conversationIds.joinToString(", ")}")
return@subscribe return@subscribe
} }