From 032c468e8a994c169513dfc42349ed4aca826619 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Mon, 27 Jun 2022 11:49:07 +0300 Subject: [PATCH] prefer user email as the username for plugins --- .gitignore | 2 ++ lib/api/messages.js | 1 + lib/api/submit.js | 1 + lib/forward.js | 3 +-- lib/maildropper.js | 7 ++++++- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 46da5152..b771b2c6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ config/production.* config/development.* package-lock.json* certs/test-* +zmta-milter +zmta-milter.toml \ No newline at end of file diff --git a/lib/api/messages.js b/lib/api/messages.js index 126e5be1..8cb11646 100644 --- a/lib/api/messages.js +++ b/lib/api/messages.js @@ -2992,6 +2992,7 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti let message = maildrop.push( { user: userData._id, + userEmail: userData.address, reason: 'submit', from: envelope.from, to: envelope.to, diff --git a/lib/api/submit.js b/lib/api/submit.js index 43a27139..d2b9fb23 100644 --- a/lib/api/submit.js +++ b/lib/api/submit.js @@ -465,6 +465,7 @@ module.exports = (db, server, messageHandler, userHandler, settingsHandler) => { let message = maildrop.push( { user: userData._id, + userEmail: userData.address, parentId: messageId, reason: 'submit', from: compiledEnvelope.from, diff --git a/lib/forward.js b/lib/forward.js index 5436c877..d139ee88 100644 --- a/lib/forward.js +++ b/lib/forward.js @@ -13,8 +13,7 @@ module.exports = (options, callback) => { targets: options.targets, - interface: 'forwarder', - runPlugins: true + interface: 'forwarder' }; let message = options.maildrop.push(mail, (err, ...args) => { diff --git a/lib/maildropper.js b/lib/maildropper.js index 0f1b5dfa..2b3b105c 100644 --- a/lib/maildropper.js +++ b/lib/maildropper.js @@ -97,7 +97,12 @@ class Maildropper { }; if (options.user) { - envelope.user = options.user.toString(); + envelope.userId = options.user.toString(); + } + + if (options.userEmail) { + // prefer email address as the username + envelope.user = options.userEmail; } if (options.parentId) {