Improve encryption check condition

This commit is contained in:
Florian Renaud 2023-03-01 13:52:53 +01:00
parent 891897f0a7
commit 245ca13049
1 changed files with 4 additions and 2 deletions

View File

@ -94,8 +94,10 @@ internal class EventDecryptor @Inject constructor(
* @param timeline the id of the timeline where the event is decrypted. It is used to prevent replay attack. * @param timeline the id of the timeline where the event is decrypted. It is used to prevent replay attack.
*/ */
suspend fun decryptEventAndSaveResult(event: Event, timeline: String) { suspend fun decryptEventAndSaveResult(event: Event, timeline: String) {
if (event.type == EventType.ENCRYPTED && event.mxDecryptionResult != null) return // event is not encrypted or already decrypted
tryOrNull(message = "Unable to decrypt the event") { if (event.getClearType() != EventType.ENCRYPTED) return
tryOrNull(message = "decryptEventAndSaveResult | Unable to decrypt the event") {
decryptEvent(event, timeline) decryptEvent(event, timeline)
} }
?.let { result -> ?.let { result ->