|
|
@ -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) {
|
|
|
|