Browse Source

Merge pull request #266 from isocolsky/fix/email_parsing

Avoid sending email if unable to apply template
activeAddress
Matias Alejo Garcia 9 years ago
parent
commit
763b30621f
  1. 2
      lib/emailservice.js
  2. 23
      test/integration/server.js

2
lib/emailservice.js

@ -140,6 +140,8 @@ EmailService.prototype._loadTemplate = function(emailType, recipient, extension,
};
EmailService.prototype._applyTemplate = function(template, data, cb) {
if (!data) return cb(new Error('Could not apply template to empty data'));
var error;
var result = _.mapValues(template, function(t) {
try {

23
test/integration/server.js

@ -388,6 +388,29 @@ describe('Wallet service', function() {
});
});
it('should not send email if unable to apply template to notification', function(done) {
var _applyTemplate_old = emailService._applyTemplate;
emailService._applyTemplate = function(template, data, cb) {
_applyTemplate_old.call(emailService, template, undefined, cb);
};
helpers.stubUtxos(server, wallet, [1, 1], function() {
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.8, 'some message', TestData.copayers[0].privKey_1H_0);
server.createTx(txOpts, function(err, tx) {
should.not.exist(err);
setTimeout(function() {
var calls = mailerStub.sendMail.getCalls();
calls.length.should.equal(0);
server.storage.fetchUnsentEmails(function(err, unsent) {
should.not.exist(err);
unsent.should.be.empty;
emailService._applyTemplate = _applyTemplate_old;
done();
});
}, 100);
});
});
});
it('should notify copayers a new outgoing tx has been created', function(done) {
helpers.stubUtxos(server, wallet, [1, 1], function() {
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.8, 'some message', TestData.copayers[0].privKey_1H_0);

Loading…
Cancel
Save