diff --git a/imap-core/lib/indexer/indexer.js b/imap-core/lib/indexer/indexer.js index 3ef08c7d..ae53d9be 100644 --- a/imap-core/lib/indexer/indexer.js +++ b/imap-core/lib/indexer/indexer.js @@ -619,17 +619,21 @@ class Indexer { } let node = nodes[pos++]; - this.attachmentStorage.create(node, (err, id) => { + this.attachmentStorage.create(node, (err, id, fileContentHash) => { if (err) { return callback(err); } mimeTree.attachmentMap[node.attachmentId] = id; - let attachmentInfo = maildata.attachments && maildata.attachments.find(a => a.id === node.attachmentId); + let attachmentInfo = maildata.attachments && maildata.attachments.find(a => a.id === node.attachmentId); // get reference to attachment info if (attachmentInfo && node.body) { attachmentInfo.size = node.body.length; } + if (fileContentHash) { + attachmentInfo.fileContentHash = fileContentHash; + } + return storeNode(); }); }; diff --git a/lib/filter-handler.js b/lib/filter-handler.js index 40ae63c4..ad9621c8 100644 --- a/lib/filter-handler.js +++ b/lib/filter-handler.js @@ -716,6 +716,12 @@ class FilterHandler { if (binaryHash) { resp.encodedSha256 = binaryHash.toString('base64'); } + + let attachmentInfo = maildata.attachments.find(a => a.id === att.id); + + if (attachmentInfo && attachmentInfo.fileContentHash) { + resp.fileContentHash = attachmentInfo.fileContentHash; + } return resp; }) }, diff --git a/test/api-test.js b/test/api-test.js index 53585f09..5a5bba7a 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -592,6 +592,7 @@ describe('API tests', function () { { contentType: 'image/png', disposition: 'inline', + fileContentHash: 'SnEfXNA8Cf15ri8Zuy9xFo5xwYt1YmJqGujZnrwyEv8=', filename: 'attachment-1.png', hash: '6bb932138c9062004611ca0170d773e78d79154923c5daaf6d8a2f27361c33a2', id: 'ATT00001',