mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
closes #3756
This commit is contained in:
@@ -41,7 +41,6 @@
|
|||||||
"no-user": "User does not exist",
|
"no-user": "User does not exist",
|
||||||
"no-teaser": "Teaser does not exist",
|
"no-teaser": "Teaser does not exist",
|
||||||
"no-privileges": "You do not have enough privileges for this action.",
|
"no-privileges": "You do not have enough privileges for this action.",
|
||||||
"no-emailers-configured": "No email plugins were loaded, so a test email could not be sent",
|
|
||||||
|
|
||||||
"category-disabled": "Category disabled",
|
"category-disabled": "Category disabled",
|
||||||
|
|
||||||
|
|||||||
@@ -22,13 +22,6 @@ dashboardController.get = function(req, res, next) {
|
|||||||
doneText: 'Reload not required',
|
doneText: 'Reload not required',
|
||||||
notDoneText:'Reload required'
|
notDoneText:'Reload required'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
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',
|
|
||||||
link:'/admin/extend/plugins'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
done: plugins.hasListeners('filter:search.query'),
|
done: plugins.hasListeners('filter:search.query'),
|
||||||
doneText: 'Search Plugin Installed',
|
doneText: 'Search Plugin Installed',
|
||||||
|
|||||||
@@ -85,13 +85,10 @@ Controllers.reset = function(req, res, next) {
|
|||||||
Controllers.login = function(req, res, next) {
|
Controllers.login = function(req, res, next) {
|
||||||
var data = {},
|
var data = {},
|
||||||
loginStrategies = require('../routes/authentication').getLoginStrategies(),
|
loginStrategies = require('../routes/authentication').getLoginStrategies(),
|
||||||
emailersPresent = plugins.hasListeners('filter:email.send');
|
registrationType = meta.config.registrationType || 'normal';
|
||||||
|
|
||||||
var registrationType = meta.config.registrationType || 'normal';
|
|
||||||
|
|
||||||
data.alternate_logins = loginStrategies.length > 0;
|
data.alternate_logins = loginStrategies.length > 0;
|
||||||
data.authentication = loginStrategies;
|
data.authentication = loginStrategies;
|
||||||
data.showResetLink = emailersPresent;
|
|
||||||
data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1 || parseInt(req.query.local, 10) === 1;
|
data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1 || parseInt(req.query.local, 10) === 1;
|
||||||
data.allowRegistration = registrationType === 'normal' || registrationType === 'admin-approval';
|
data.allowRegistration = registrationType === 'normal' || registrationType === 'admin-approval';
|
||||||
data.allowLoginWith = '[[login:' + (meta.config.allowLoginWith || 'username-email') + ']]';
|
data.allowLoginWith = '[[login:' + (meta.config.allowLoginWith || 'username-email') + ']]';
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var fs = require('fs'),
|
var async = require('async'),
|
||||||
async = require('async'),
|
|
||||||
path = require('path'),
|
|
||||||
winston = require('winston'),
|
winston = require('winston'),
|
||||||
templates = require('templates.js'),
|
templates = require('templates.js'),
|
||||||
|
nodemailer = require('nodemailer'),
|
||||||
|
|
||||||
User = require('./user'),
|
User = require('./user'),
|
||||||
Plugins = require('./plugins'),
|
Plugins = require('./plugins'),
|
||||||
@@ -45,49 +44,18 @@ var fs = require('fs'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
Emailer.sendToEmail = function(template, email, language, params, callback) {
|
Emailer.sendToEmail = function(template, email, language, params, callback) {
|
||||||
function renderAndTranslate(tpl, params, callback) {
|
|
||||||
async.waterfall([
|
|
||||||
function(next) {
|
|
||||||
render('emails/partials/footer' + (tpl.indexOf('_plaintext') !== -1 ? '_plaintext' : ''), params, next);
|
|
||||||
},
|
|
||||||
function(footer, next) {
|
|
||||||
params.footer = footer;
|
|
||||||
render(tpl, params, next);
|
|
||||||
},
|
|
||||||
function(html, next) {
|
|
||||||
translator.translate(html, lang, function(translated) {
|
|
||||||
next(null, translated);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
], callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
function render(tpl, params, next) {
|
|
||||||
if (meta.config['email:custom:' + tpl.replace('emails/', '')]) {
|
|
||||||
var text = templates.parse(meta.config['email:custom:' + tpl.replace('emails/', '')], params);
|
|
||||||
next(null, text);
|
|
||||||
} else {
|
|
||||||
app.render(tpl, params, next);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
callback = callback || function() {};
|
callback = callback || function() {};
|
||||||
|
|
||||||
if (!Plugins.hasListeners('filter:email.send')) {
|
|
||||||
winston.warn('[emailer] No active email plugin found to send "' + template + '" email');
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
|
|
||||||
var lang = language || meta.config.defaultLang || 'en_GB';
|
var lang = language || meta.config.defaultLang || 'en_GB';
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
html: function(next) {
|
html: function(next) {
|
||||||
renderAndTranslate('emails/' + template, params, next);
|
renderAndTranslate('emails/' + template, params, lang, next);
|
||||||
},
|
},
|
||||||
plaintext: function(next) {
|
plaintext: function(next) {
|
||||||
renderAndTranslate('emails/' + template + '_plaintext', params, next);
|
renderAndTranslate('emails/' + template + '_plaintext', params, lang, next);
|
||||||
},
|
},
|
||||||
subject: function(next) {
|
subject: function(next) {
|
||||||
translator.translate(params.subject, lang, function(translated) {
|
translator.translate(params.subject, lang, function(translated) {
|
||||||
@@ -112,14 +80,51 @@ var fs = require('fs'),
|
|||||||
Plugins.fireHook('filter:email.modify', data, next);
|
Plugins.fireHook('filter:email.modify', data, next);
|
||||||
},
|
},
|
||||||
function (data, next) {
|
function (data, next) {
|
||||||
|
if (Plugins.hasListeners('filter:email.send')) {
|
||||||
Plugins.fireHook('filter:email.send', data, next);
|
Plugins.fireHook('filter:email.send', data, next);
|
||||||
|
} else {
|
||||||
|
Emailer.sendViaFallback(data, next);
|
||||||
}
|
}
|
||||||
], function (err, data) {
|
}
|
||||||
|
], function (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Emailer.sendViaFallback = function(data, callback) {
|
||||||
|
// Some minor alterations to the data to conform to nodemailer standard
|
||||||
|
data.text = data.plaintext;
|
||||||
|
delete data.plaintext;
|
||||||
|
|
||||||
|
nodemailer.mail(data);
|
||||||
|
callback(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
function render(tpl, params, next) {
|
||||||
|
if (meta.config['email:custom:' + tpl.replace('emails/', '')]) {
|
||||||
|
var text = templates.parse(meta.config['email:custom:' + tpl.replace('emails/', '')], params);
|
||||||
|
next(null, text);
|
||||||
|
} else {
|
||||||
|
app.render(tpl, params, next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderAndTranslate(tpl, params, lang, callback) {
|
||||||
|
async.waterfall([
|
||||||
|
function(next) {
|
||||||
|
render('emails/partials/footer' + (tpl.indexOf('_plaintext') !== -1 ? '_plaintext' : ''), params, next);
|
||||||
|
},
|
||||||
|
function(footer, next) {
|
||||||
|
params.footer = footer;
|
||||||
|
render(tpl, params, next);
|
||||||
|
},
|
||||||
|
function(html, next) {
|
||||||
|
translator.translate(html, lang, function(translated) {
|
||||||
|
next(null, translated);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
], callback);
|
||||||
|
}
|
||||||
|
|
||||||
}(module.exports));
|
}(module.exports));
|
||||||
|
|
||||||
|
|||||||
@@ -199,14 +199,10 @@ SocketAdmin.settings.clearSitemapCache = function(socket, data, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SocketAdmin.email.test = function(socket, data, callback) {
|
SocketAdmin.email.test = function(socket, data, callback) {
|
||||||
if (plugins.hasListeners('filter:email.send')) {
|
|
||||||
emailer.send(data.template, socket.uid, {
|
emailer.send(data.template, socket.uid, {
|
||||||
subject: '[NodeBB] Test Email',
|
subject: '[NodeBB] Test Email',
|
||||||
site_title: meta.config.title || 'NodeBB'
|
site_title: meta.config.title || 'NodeBB'
|
||||||
}, callback);
|
}, callback);
|
||||||
} else {
|
|
||||||
callback(new Error('[[error:no-emailers-configured]]'));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketAdmin.analytics.get = function(socket, data, callback) {
|
SocketAdmin.analytics.get = function(socket, data, callback) {
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ var async = require('async'),
|
|||||||
return winston.verbose('[user/jobs] Did not send digests (' + interval + ') because subscription system is disabled.');
|
return winston.verbose('[user/jobs] Did not send digests (' + interval + ') because subscription system is disabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugins.hasListeners('filter:email.send')) {
|
|
||||||
return winston.error('[user/jobs] Did not send digests (' + interval + ') because no active email plugin was found.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!interval) {
|
if (!interval) {
|
||||||
// interval is one of: day, week, month, or year
|
// interval is one of: day, week, month, or year
|
||||||
interval = 'day';
|
interval = 'day';
|
||||||
|
|||||||
Reference in New Issue
Block a user