fixed emailer templates

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

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

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

Loading…
Cancel
Save