From c2e2370655ab1014893ecca8732575f95f794efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 18 Jan 2021 13:34:28 -0500 Subject: [PATCH] feat: add filter:email.cancel to allow plugins to cancel sending emails --- src/emailer.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/emailer.js b/src/emailer.js index 7a2fcdc46d..f1717ccb26 100644 --- a/src/emailer.js +++ b/src/emailer.js @@ -230,6 +230,16 @@ Emailer.send = async (template, uid, params) => { params.uid = uid; params.username = userData.username; params.rtl = await translator.translate('[[language:dir]]', userSettings.userLang) === 'rtl'; + + const result = await Plugins.hooks.fire('filter:email.cancel', { + cancel: false, // set to true in plugin to cancel sending email + template: template, + params: params, + }); + + if (result.cancel) { + return; + } await Emailer.sendToEmail(template, userData.email, userSettings.userLang, params); };