fixed emailer templates

v1.18.x
psychobunny 11 years ago
parent b2986f2a4e
commit 6563a72b5b

@ -1,3 +1,5 @@
"use strict";
var fs = require('fs'),
async = require('async'),
path = require('path'),
@ -9,27 +11,22 @@ var fs = require('fs'),
Translator = require('../public/src/translator'),
templates = require('../public/src/templates'),
app = {},
Emailer = {};
var render = function(template, params, callback) {
if (templates[template]) {
Translator.translate(templates[template].parse(params), function(template) {
callback(null, template);
});
} else {
callback(null, null);
}
}
Emailer.registerApp = function(expressApp) {
app = expressApp;
return Emailer;
};
Emailer.send = function(template, uid, params) {
async.parallel({
html: function(next) {
render('emails/' + template, params, next);
app.render('emails/' + template, params, next);
},
plaintext: function(next) {
render('emails/' + template + '_plaintext', params, next);
app.render('emails/' + template + '_plaintext', params, next);
}
}, function(err, results) {
User.getUserField(uid, 'email', function(err, email) {

@ -8,6 +8,7 @@ var path = require('path'),
winston = require('winston'),
async = require('async'),
emailer = require('./emailer'),
db = require('./database'),
auth = require('./routes/authentication'),
meta = require('./meta'),
@ -31,6 +32,7 @@ if(nconf.get('ssl')) {
logger.init(app);
auth.registerApp(app);
emailer.registerApp(app);
async.series({
themesData: meta.themes.get,

Loading…
Cancel
Save