2017-09-27 15:44:51 +00:00
|
|
|
var path = require('path');
|
|
|
|
var database = require(path.join(__dirname, '../../database.js'));
|
|
|
|
var locale = require(path.join(__dirname, '../../locale.js'));
|
|
|
|
|
|
|
|
module.exports = class NotificationAlias {
|
|
|
|
getData(params, cb) {
|
|
|
|
this.params = params;
|
|
|
|
|
|
|
|
let query = `SELECT alias, CONCAT(alias, '@verdnatura.es') AS recipient
|
|
|
|
FROM account.mailAlias
|
|
|
|
WHERE alias = ?`;
|
|
|
|
|
|
|
|
database.pool.query(query, [params.alias], (error, result) => {
|
|
|
|
if (error || result.length == 0)
|
2017-10-17 06:22:59 +00:00
|
|
|
return cb(new Error('No template data found'));
|
2017-09-27 15:44:51 +00:00
|
|
|
|
|
|
|
Object.assign(this, result[0]);
|
2017-10-17 06:22:59 +00:00
|
|
|
cb();
|
2017-09-27 15:44:51 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
get subject() {
|
|
|
|
return this._.notificationCode[this.params.code].subject;
|
|
|
|
}
|
|
|
|
|
|
|
|
get message() {
|
|
|
|
return locale.parseText(this._.notificationCode[this.params.code].message, this.params.bodyParams);
|
|
|
|
}
|
|
|
|
};
|