This commit is contained in:
Andris Reinman 2018-09-21 12:44:07 +03:00
parent d8979f158a
commit ed9231d0fd
2 changed files with 21 additions and 1 deletions

View file

@ -137,6 +137,8 @@ class FilterHandler {
let sender = options.sender || ''; let sender = options.sender || '';
let recipient = options.recipient || userData.address; let recipient = options.recipient || userData.address;
let filterResults = [];
// create Delivered-To and Return-Path headers // create Delivered-To and Return-Path headers
let extraHeader = Buffer.from(['Delivered-To: ' + recipient, 'Return-Path: <' + sender + '>'].join('\r\n') + '\r\n'); let extraHeader = Buffer.from(['Delivered-To: ' + recipient, 'Return-Path: <' + sender + '>'].join('\r\n') + '\r\n');
@ -473,6 +475,12 @@ class FilterHandler {
err.message err.message
); );
} else if (id) { } else if (id) {
filterResults.push({
forward: Array.from(forwardTargets)
.map(row => row[0])
.join(','),
'forward-queue-id': id
});
outbound.push(id); outbound.push(id);
log.silly( log.silly(
'LMTP', 'LMTP',
@ -491,6 +499,7 @@ class FilterHandler {
if (err) { if (err) {
log.error('LMTP', '%s AUTOREPLYFAIL from=%s to=%s error=%s', prepared.id.toString(), '<>', sender, err.message); log.error('LMTP', '%s AUTOREPLYFAIL from=%s to=%s error=%s', prepared.id.toString(), '<>', sender, err.message);
} else if (id) { } else if (id) {
filterResults.push({ autoreply: sender, 'autoreply-queue-id': id });
outbound.push(id); outbound.push(id);
log.silly('LMTP', '%s AUTOREPLYOK id=%s from=%s to=%s', prepared.id.toString(), id, '<>', sender); log.silly('LMTP', '%s AUTOREPLYOK id=%s from=%s to=%s', prepared.id.toString(), id, '<>', sender);
} }
@ -500,6 +509,8 @@ class FilterHandler {
let err = new Error('Message dropped by policy'); let err = new Error('Message dropped by policy');
err.code = 'DroppedByPolicy'; err.code = 'DroppedByPolicy';
filterResults.push({ delete: true });
return callback(null, { return callback(null, {
userData, userData,
response: 'Message dropped by policy as ' + prepared.id.toString(), response: 'Message dropped by policy as ' + prepared.id.toString(),
@ -515,16 +526,19 @@ class FilterHandler {
// positive value is spam // positive value is spam
mailboxQueryKey = 'specialUse'; mailboxQueryKey = 'specialUse';
mailboxQueryValue = '\\Junk'; mailboxQueryValue = '\\Junk';
filterResults.push({ spam: true });
} }
break; break;
case 'seen': case 'seen':
if (value) { if (value) {
flags.push('\\Seen'); flags.push('\\Seen');
filterResults.push({ seen: true });
} }
break; break;
case 'flag': case 'flag':
if (value) { if (value) {
flags.push('\\Flagged'); flags.push('\\Flagged');
filterResults.push({ flagged: true });
} }
break; break;
case 'mailbox': case 'mailbox':
@ -571,15 +585,21 @@ class FilterHandler {
// make sure we have the updated message structure values // make sure we have the updated message structure values
messageOpts.prepared = prepared; messageOpts.prepared = prepared;
messageOpts.maildata = maildata; messageOpts.maildata = maildata;
filterResults.push({ encrypted: true });
} }
this.messageHandler.add(messageOpts, (err, inserted, info) => { this.messageHandler.add(messageOpts, (err, inserted, info) => {
if (info) {
filterResults.push({ mailbox: info.mailbox && info.mailbox.toString(), id: info.id && info.id.toString() });
}
// push to response list // push to response list
callback( callback(
null, null,
{ {
userData, userData,
response: err ? err : 'Message stored as ' + info.id.toString(), response: err ? err : 'Message stored as ' + info.id.toString(),
filterResults,
error: err error: err
}, },
(!isEncrypted && { (!isEncrypted && {

View file

@ -1,6 +1,6 @@
{ {
"name": "wildduck", "name": "wildduck",
"version": "1.4.13", "version": "1.4.14",
"description": "IMAP/POP3 server built with Node.js and MongoDB", "description": "IMAP/POP3 server built with Node.js and MongoDB",
"main": "server.js", "main": "server.js",
"scripts": { "scripts": {