From ed9231d0fdd940de0bde3b966887a8c40d5a3ee8 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Fri, 21 Sep 2018 12:44:07 +0300 Subject: [PATCH] v1.4.14 --- lib/filter-handler.js | 20 ++++++++++++++++++++ package.json | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/filter-handler.js b/lib/filter-handler.js index a6ad0963..789c369b 100644 --- a/lib/filter-handler.js +++ b/lib/filter-handler.js @@ -137,6 +137,8 @@ class FilterHandler { let sender = options.sender || ''; let recipient = options.recipient || userData.address; + let filterResults = []; + // create Delivered-To and Return-Path headers let extraHeader = Buffer.from(['Delivered-To: ' + recipient, 'Return-Path: <' + sender + '>'].join('\r\n') + '\r\n'); @@ -473,6 +475,12 @@ class FilterHandler { err.message ); } else if (id) { + filterResults.push({ + forward: Array.from(forwardTargets) + .map(row => row[0]) + .join(','), + 'forward-queue-id': id + }); outbound.push(id); log.silly( 'LMTP', @@ -491,6 +499,7 @@ class FilterHandler { if (err) { log.error('LMTP', '%s AUTOREPLYFAIL from=%s to=%s error=%s', prepared.id.toString(), '<>', sender, err.message); } else if (id) { + filterResults.push({ autoreply: sender, 'autoreply-queue-id': id }); outbound.push(id); 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'); err.code = 'DroppedByPolicy'; + filterResults.push({ delete: true }); + return callback(null, { userData, response: 'Message dropped by policy as ' + prepared.id.toString(), @@ -515,16 +526,19 @@ class FilterHandler { // positive value is spam mailboxQueryKey = 'specialUse'; mailboxQueryValue = '\\Junk'; + filterResults.push({ spam: true }); } break; case 'seen': if (value) { flags.push('\\Seen'); + filterResults.push({ seen: true }); } break; case 'flag': if (value) { flags.push('\\Flagged'); + filterResults.push({ flagged: true }); } break; case 'mailbox': @@ -571,15 +585,21 @@ class FilterHandler { // make sure we have the updated message structure values messageOpts.prepared = prepared; messageOpts.maildata = maildata; + filterResults.push({ encrypted: true }); } 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 callback( null, { userData, response: err ? err : 'Message stored as ' + info.id.toString(), + filterResults, error: err }, (!isEncrypted && { diff --git a/package.json b/package.json index aea4d887..de66ae06 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wildduck", - "version": "1.4.13", + "version": "1.4.14", "description": "IMAP/POP3 server built with Node.js and MongoDB", "main": "server.js", "scripts": {