From dbf0f279a2d061a244b0d28a3681fb59e84abb00 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 22 Sep 2015 17:22:49 -0400 Subject: [PATCH] closes #3644 --- src/controllers/admin/dashboard.js | 2 +- src/controllers/index.js | 2 +- src/emailer.js | 9 ++++----- src/socket.io/admin.js | 5 ++--- src/user/digest.js | 2 +- src/user/email.js | 5 +---- src/user/invite.js | 7 +------ 7 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/controllers/admin/dashboard.js b/src/controllers/admin/dashboard.js index 7575a19411..03acb0091f 100644 --- a/src/controllers/admin/dashboard.js +++ b/src/controllers/admin/dashboard.js @@ -23,7 +23,7 @@ dashboardController.get = function(req, res, next) { notDoneText:'Reload required' }, { - done: plugins.hasListeners('action:email.send'), + done: plugins.hasListeners('filter:email.send'), doneText: 'Emailer Installed', notDoneText:'Emailer not installed', tooltip:'Install an emailer plugin from the plugin page in order to activate registration emails and email digests', diff --git a/src/controllers/index.js b/src/controllers/index.js index 998d6f3caa..88d906e22c 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -79,7 +79,7 @@ Controllers.reset = function(req, res, next) { Controllers.login = function(req, res, next) { var data = {}, loginStrategies = require('../routes/authentication').getLoginStrategies(), - emailersPresent = plugins.hasListeners('action:email.send'); + emailersPresent = plugins.hasListeners('filter:email.send'); var registrationType = meta.config.registrationType || 'normal'; diff --git a/src/emailer.js b/src/emailer.js index 4f2e59c325..06f2abc757 100644 --- a/src/emailer.js +++ b/src/emailer.js @@ -74,8 +74,8 @@ var fs = require('fs'), callback = callback || function() {}; - if (!Plugins.hasListeners('action:email.send')) { - winston.warn('[emailer] No active email plugin found!'); + if (!Plugins.hasListeners('filter:email.send')) { + winston.warn('[emailer] No active email plugin found to send "' + template + '" email'); return callback(); } @@ -110,11 +110,10 @@ var fs = require('fs'), pid: params.pid, fromUid: params.fromUid }; - Plugins.fireHook('filter:email.send', data, next); + Plugins.fireHook('filter:email.modify', data, next); }, function (data, next) { - Plugins.fireHook('action:email.send', data); - next(); + Plugins.fireHook('filter:email.send', data, next); } ], callback); }; diff --git a/src/socket.io/admin.js b/src/socket.io/admin.js index 77df65467c..15c482ffa0 100644 --- a/src/socket.io/admin.js +++ b/src/socket.io/admin.js @@ -198,12 +198,11 @@ SocketAdmin.settings.clearSitemapCache = function(socket, data, callback) { }; SocketAdmin.email.test = function(socket, data, callback) { - if (plugins.hasListeners('action:email.send')) { + if (plugins.hasListeners('filter:email.send')) { emailer.send(data.template, socket.uid, { subject: '[NodeBB] Test Email', site_title: meta.config.title || 'NodeBB' - }); - callback(); + }, callback); } else { callback(new Error('[[error:no-emailers-configured]]')); } diff --git a/src/user/digest.js b/src/user/digest.js index c1656d45c8..65023a1402 100644 --- a/src/user/digest.js +++ b/src/user/digest.js @@ -20,7 +20,7 @@ var async = require('async'), return winston.verbose('[user/jobs] Did not send digests (' + interval + ') because subscription system is disabled.'); } - if (!plugins.hasListeners('action:email.send')) { + if (!plugins.hasListeners('filter:email.send')) { return winston.error('[user/jobs] Did not send digests (' + interval + ') because no active email plugin was found.'); } diff --git a/src/user/email.js b/src/user/email.js index c982cb53d5..9a1dfde805 100644 --- a/src/user/email.js +++ b/src/user/email.js @@ -80,11 +80,8 @@ var async = require('async'), if (plugins.hasListeners('action:user.verify')) { plugins.fireHook('action:user.verify', {uid: uid, data: data}); next(); - } else if (plugins.hasListeners('action:email.send')) { - emailer.send('welcome', uid, data, next); } else { - winston.warn('No emailer to send verification email!'); - next(); + emailer.send('welcome', uid, data, next); } }); } diff --git a/src/user/invite.js b/src/user/invite.js index 9ea271b397..0fb8ae979b 100644 --- a/src/user/invite.js +++ b/src/user/invite.js @@ -43,12 +43,7 @@ module.exports = function(User) { template: 'invitation' }; - if (plugins.hasListeners('action:email.send')) { - emailer.sendToEmail('invitation', email, meta.config.defaultLang, data, next); - } else { - winston.warn('No emailer to send verification email!'); - next(); - } + emailer.sendToEmail('invitation', email, meta.config.defaultLang, data, next); }); } ], callback);