mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-09-09 22:55:41 +08:00
fix(handler-filter): Filter handler response includes file content sha256 hash ZMS-176 (#739)
* filter handler response includes file content sha256 hash * fix tests
This commit is contained in:
parent
6dac6ae256
commit
37374be439
3 changed files with 13 additions and 2 deletions
|
@ -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();
|
||||
});
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
})
|
||||
},
|
||||
|
|
|
@ -592,6 +592,7 @@ describe('API tests', function () {
|
|||
{
|
||||
contentType: 'image/png',
|
||||
disposition: 'inline',
|
||||
fileContentHash: 'SnEfXNA8Cf15ri8Zuy9xFo5xwYt1YmJqGujZnrwyEv8=',
|
||||
filename: 'attachment-1.png',
|
||||
hash: '6bb932138c9062004611ca0170d773e78d79154923c5daaf6d8a2f27361c33a2',
|
||||
id: 'ATT00001',
|
||||
|
|
Loading…
Add table
Reference in a new issue