remove subject from html templates

This commit is contained in:
Ivan Socolsky 2015-07-03 14:24:24 -03:00
parent 470df32a09
commit b1cc7407ee
2 changed files with 7 additions and 4 deletions

View File

@ -109,8 +109,11 @@ EmailService.prototype.start = function(opts, cb) {
});
};
EmailService.prototype._compileTemplate = function(template) {
EmailService.prototype._compileTemplate = function(template, extension) {
var lines = template.split('\n');
if (extension == '.html') {
lines.unshift('');
}
return {
subject: lines[0],
body: _.rest(lines).join('\n'),
@ -135,7 +138,7 @@ EmailService.prototype._loadTemplate = function(emailType, recipient, extension,
self._readTemplateFile(recipient.language, emailType.filename + extension, function(err, template) {
if (err) return cb(err);
return cb(null, self._compileTemplate(template));
return cb(null, self._compileTemplate(template, extension));
});
};

View File

@ -353,7 +353,7 @@ describe('Wallet service', function() {
var _readTemplateFile_old = emailService._readTemplateFile;
emailService._readTemplateFile = function(language, filename, cb) {
if (_.endsWith(filename, '.html')) {
return cb(null, 'Subject\n<html><body>{{walletName}}</body></html>');
return cb(null, '<html><body>{{walletName}}</body></html>');
} else {
_readTemplateFile_old.call(emailService, language, filename, cb);
}
@ -375,7 +375,7 @@ describe('Wallet service', function() {
one.text.should.contain(wallet.name);
one.text.should.contain(wallet.copayers[0].name);
should.exist(one.html);
one.html.should.contain('<body>');
one.html.indexOf('<html>').should.equal(0);
one.html.should.contain(wallet.name);
server.storage.fetchUnsentEmails(function(err, unsent) {
should.not.exist(err);