include hash value in attachment output

This commit is contained in:
Andris Reinman 2021-03-26 09:58:05 +02:00
parent b01da3a183
commit 20fda17be4
9 changed files with 28 additions and 28 deletions

View file

@ -2760,6 +2760,9 @@ components:
id:
type: string
description: Attachment ID
hash:
type: string
description: SHA-256 hash of the contents of the attachment
filename:
type: string
description: Filename of the attachment

View file

@ -850,6 +850,7 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler) => {
thread: true,
hdate: true,
'mimeTree.parsedHeader': true,
'mimeTree.attachmentMap': true,
subject: true,
msgid: true,
exp: true,
@ -1010,7 +1011,13 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler) => {
html: messageData.html,
text: messageData.text,
forwardTargets: messageData.forwardTargets,
attachments: messageData.attachments || [],
attachments: (messageData.attachments || []).map(attachmentData => {
let hash = messageData.mimeTree && messageData.mimeTree.attachmentMap && messageData.mimeTree.attachmentMap[attachmentData.id];
if (!hash) {
return attachmentData;
}
return Object.assign({ hash: hash.toString('hex') }, attachmentData);
}),
references: (parsedHeader.references || '')
.toString()
.split(/\s+/)

View file

@ -8,7 +8,6 @@ const roles = require('../roles');
const { nextPageCursorSchema, previousPageCursorSchema, pageNrSchema, sessSchema, sessIPSchema } = require('../schemas');
module.exports = (db, server) => {
server.get(
{ name: 'webhooks', path: '/webhooks' },
tools.asyncifyJson(async (req, res, next) => {

View file

@ -128,10 +128,7 @@ module.exports = (options, autoreplyData, callback) => {
);
if (message) {
compiler
.compile()
.createReadStream()
.pipe(message);
compiler.compile().createReadStream().pipe(message);
}
});
});

View file

@ -133,9 +133,7 @@ class HeaderSplitter extends Transform {
}
};
processChunk()
.then(callback)
.catch(callback);
processChunk().then(callback).catch(callback);
}
_flush(callback) {

View file

@ -285,9 +285,7 @@ class POP3Server extends EventEmitter {
socket.unshift(remainder);
}
let header = Buffer.concat(chunks, chunklen)
.toString()
.trim();
let header = Buffer.concat(chunks, chunklen).toString().trim();
let params = (header || '').toString().split(' ');
let commandName = params.shift().toUpperCase();

View file

@ -4,10 +4,7 @@ const log = require('npmlog');
const db = require('../db');
module.exports = (taskData, options, callback) => {
let cursor = db.users
.collection('users')
.find({})
.project({ _id: true, storageUsed: true });
let cursor = db.users.collection('users').find({}).project({ _id: true, storageUsed: true });
let processNext = () => {
cursor.next((err, userData) => {

View file

@ -1,6 +1,6 @@
{
"name": "wildduck",
"version": "1.32.3",
"version": "1.32.4",
"description": "IMAP/POP3 server built with Node.js and MongoDB",
"main": "server.js",
"scripts": {
@ -16,21 +16,21 @@
"author": "Andris Reinman",
"license": "EUPL-1.2",
"devDependencies": {
"ajv": "7.1.1",
"chai": "4.3.0",
"docsify-cli": "4.4.2",
"eslint": "7.20.0",
"ajv": "7.2.3",
"chai": "4.3.4",
"docsify-cli": "4.4.3",
"eslint": "7.22.0",
"eslint-config-nodemailer": "1.2.0",
"eslint-config-prettier": "8.1.0",
"grunt": "1.3.0",
"grunt-cli": "1.3.2",
"grunt-cli": "1.4.1",
"grunt-eslint": "23.0.0",
"grunt-mocha-test": "0.13.3",
"grunt-shell-spawn": "0.4.0",
"grunt-wait": "0.3.0",
"imapflow": "1.0.53",
"imapflow": "1.0.56",
"mailparser": "3.1.0",
"mocha": "8.3.0",
"mocha": "8.3.2",
"request": "2.88.2",
"supertest": "6.1.3"
},
@ -41,7 +41,7 @@
"axios": "0.21.1",
"base32.js": "0.1.0",
"bcryptjs": "2.4.3",
"bull": "3.20.1",
"bull": "3.22.0",
"gelf": "2.0.1",
"generate-password": "1.6.0",
"he": "1.2.0",
@ -49,7 +49,7 @@
"humanname": "0.2.2",
"iconv-lite": "0.6.2",
"ioredfour": "1.0.2-ioredis-03",
"ioredis": "4.23.0",
"ioredis": "4.24.4",
"isemail": "3.2.0",
"joi": "17.4.0",
"js-yaml": "4.0.0",
@ -59,8 +59,8 @@
"libqp": "1.1.0",
"mailsplit": "5.0.1",
"mobileconfig": "2.3.1",
"mongo-cursor-pagination": "7.3.1",
"mongodb": "3.6.4",
"mongo-cursor-pagination": "7.4.0",
"mongodb": "3.6.5",
"mongodb-extended-json": "1.11.0",
"node-forge": "0.10.0",
"nodemailer": "6.5.0",

View file

@ -514,6 +514,7 @@ describe('API tests', function () {
contentType: 'image/png',
disposition: 'attachment',
filename: 'attachment-1.png',
hash: '6bb932138c9062004611ca0170d773e78d79154923c5daaf6d8a2f27361c33a2',
id: 'ATT00001',
related: true,
size: 118,