From 214d3250fe9abc30e7ec9c365acec2d6ab222a69 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Mon, 3 Oct 2022 21:49:37 +0200 Subject: [PATCH] feat(service): Mark message if the chat is encrypted while the file isn't --- lib/service/httpfiletransfer/httpfiletransfer.dart | 9 +++++++-- lib/shared/error_types.dart | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/service/httpfiletransfer/httpfiletransfer.dart b/lib/service/httpfiletransfer/httpfiletransfer.dart index 33bd825d..1d177e1c 100644 --- a/lib/service/httpfiletransfer/httpfiletransfer.dart +++ b/lib/service/httpfiletransfer/httpfiletransfer.dart @@ -355,7 +355,10 @@ class HttpFileTransferService { _log.warning('HTTP GET of ${job.location.url} returned ${response?.statusCode}'); } else { var integrityCheckPassed = true; - if (job.location.key != null && job.location.iv != null) { + final conv = (await GetIt.I.get() + .getConversationByJid(job.conversationJid))!; + final decryptionKeysAvailable = job.location.key != null && job.location.iv != null; + if (decryptionKeysAvailable) { // The file was downloaded and is now being decrypted sendEvent( ProgressEvent( @@ -425,6 +428,9 @@ class HttpFileTransferService { warningType: integrityCheckPassed ? warningFileIntegrityCheckFailed : null, + errorType: conv.encrypted && !decryptionKeysAvailable ? + messageChatEncryptedButFileNot : + null, isDownloading: false, ); @@ -435,7 +441,6 @@ class HttpFileTransferService { await notification.showNotification(msg, ''); } - final conv = (await GetIt.I.get().getConversationByJid(job.conversationJid))!; final sharedMedium = await GetIt.I.get().addSharedMediumFromData( downloadedPath, msg.timestamp, diff --git a/lib/shared/error_types.dart b/lib/shared/error_types.dart index 803bbdee..90bbfc48 100644 --- a/lib/shared/error_types.dart +++ b/lib/shared/error_types.dart @@ -11,6 +11,7 @@ const messageInvalidNumber = 6; const messageFailedToEncrypt = 7; const messageFailedToDecryptFile = 8; const messageContactDoesNotSupportOmemo = 9; +const messageChatEncryptedButFileNot = 10; int errorTypeFromException(dynamic exception) { if (exception is NoDecryptionKeyException) {