From 734b0134d6488699f9fe9a5b4ae80c71b23b0d34 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Thu, 10 Aug 2023 13:35:59 +0300 Subject: [PATCH] Include attachment sha256 in the filtering response --- lib/filter-handler.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/filter-handler.js b/lib/filter-handler.js index f423b03d..05c29947 100644 --- a/lib/filter-handler.js +++ b/lib/filter-handler.js @@ -697,7 +697,6 @@ class FilterHandler { try { let { data } = await this.addMessage(messageOpts); - if (data) { filterResults.push({ mailbox: data.mailbox && data.mailbox.toString(), @@ -711,7 +710,14 @@ class FilterHandler { userData, response: 'Message stored as ' + data.id.toString(), filterResults, - attachments: (maildata && maildata.attachments) || [] + attachments: [].concat((maildata && maildata.attachments) || []).map(att => { + let binaryHash = prepared.mimeTree?.attachmentMap?.[att.id]; + let resp = Object.assign({}, att); // cheap copy + if (binaryHash) { + resp.encodedSha256 = binaryHash.toString('base64'); + } + return resp; + }) }, prepared: (!isEncrypted && {