mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 18:56:15 +01:00
Update Nodemailer to v4
also filter out .jst files from email template dropdowns
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
var async = require('async');
|
||||
var nconf = require('nconf');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
var meta = require('../../meta');
|
||||
var file = require('../../file');
|
||||
var emailer = require('../../emailer');
|
||||
|
||||
var settingsController = module.exports;
|
||||
|
||||
@@ -22,44 +26,54 @@ settingsController.get = function (req, res, next) {
|
||||
|
||||
|
||||
function renderEmail(req, res, next) {
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var file = require('../../file');
|
||||
|
||||
var emailsPath = path.join(nconf.get('views_dir'), 'emails');
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
file.walk(emailsPath, next);
|
||||
},
|
||||
function (emails, next) {
|
||||
async.map(emails, function (email, next) {
|
||||
var path = email.replace(emailsPath, '').substr(1).replace('.tpl', '');
|
||||
async.parallel({
|
||||
emails: function (cb) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
file.walk(emailsPath, next);
|
||||
},
|
||||
function (emails, next) {
|
||||
// exclude .jst files
|
||||
emails = emails.filter(function (email) {
|
||||
return !email.endsWith('.jst');
|
||||
});
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
fs.readFile(email, next);
|
||||
},
|
||||
function (original, next) {
|
||||
var text = meta.config['email:custom:' + path] ? meta.config['email:custom:' + path] : original.toString();
|
||||
async.map(emails, function (email, next) {
|
||||
var path = email.replace(emailsPath, '').substr(1).replace('.tpl', '');
|
||||
|
||||
next(null, {
|
||||
path: path,
|
||||
fullpath: email,
|
||||
text: text,
|
||||
original: original.toString(),
|
||||
});
|
||||
},
|
||||
], next);
|
||||
}, next);
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
fs.readFile(email, next);
|
||||
},
|
||||
function (original, next) {
|
||||
var text = meta.config['email:custom:' + path] ? meta.config['email:custom:' + path] : original.toString();
|
||||
|
||||
next(null, {
|
||||
path: path,
|
||||
fullpath: email,
|
||||
text: text,
|
||||
original: original.toString(),
|
||||
});
|
||||
},
|
||||
], next);
|
||||
}, next);
|
||||
},
|
||||
], cb);
|
||||
},
|
||||
function (emails) {
|
||||
res.render('admin/settings/email', {
|
||||
emails: emails,
|
||||
sendable: emails.filter(function (email) {
|
||||
return email.path.indexOf('_plaintext') === -1 && email.path.indexOf('partials') === -1;
|
||||
}),
|
||||
});
|
||||
},
|
||||
], next);
|
||||
services: emailer.listServices,
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
res.render('admin/settings/email', {
|
||||
emails: results.emails,
|
||||
sendable: results.emails.filter(function (email) {
|
||||
return email.path.indexOf('_plaintext') === -1 && email.path.indexOf('partials') === -1;
|
||||
}),
|
||||
services: results.services,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user