send email
This commit is contained in:
parent
c621d1c573
commit
8df8327395
|
@ -21,26 +21,37 @@ var EMAIL_TYPES = {
|
|||
'NewCopayer': {
|
||||
filename: 'new_copayer',
|
||||
notifyDoer: false,
|
||||
notifyOthers: true,
|
||||
},
|
||||
'WalletComplete': {
|
||||
filename: 'wallet_complete',
|
||||
notifyDoer: true,
|
||||
notifyOthers: true,
|
||||
},
|
||||
'NewTxProposal': {
|
||||
filename: 'new_tx_proposal',
|
||||
notifyDoer: false,
|
||||
notifyOthers: true,
|
||||
},
|
||||
'NewOutgoingTx': {
|
||||
filename: 'new_outgoing_tx',
|
||||
notifyDoer: true,
|
||||
notifyOthers: true,
|
||||
},
|
||||
'NewIncomingTx': {
|
||||
filename: 'new_incoming_tx',
|
||||
notifyDoer: true,
|
||||
notifyOthers: true,
|
||||
},
|
||||
'TxProposalFinallyRejected': {
|
||||
filename: 'txp_finally_rejected',
|
||||
notifyDoer: false,
|
||||
notifyOthers: true,
|
||||
},
|
||||
'TxConfirmation': {
|
||||
filename: 'tx_confirmation',
|
||||
notifyDoer: true,
|
||||
notifyOthers: false,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -172,6 +183,7 @@ EmailService.prototype._getRecipientsList = function(notification, emailType, cb
|
|||
|
||||
usedEmails[p.email] = true;
|
||||
if (notification.creatorId == p.copayerId && !emailType.notifyDoer) return;
|
||||
if (notification.creatorId != p.copayerId && !emailType.notifyOthers) return;
|
||||
if (!_.contains(self.availableLanguages, p.language)) {
|
||||
if (p.language) {
|
||||
log.warn('Language for email "' + p.language + '" not available.');
|
||||
|
|
|
@ -231,8 +231,6 @@ PushNotificationsService.prototype._getRecipientsList = function(notification, n
|
|||
}
|
||||
}
|
||||
}));
|
||||
console.log('*** [pushnotificationsservice.js ln234] recipientsList:', recipientsList); // TODO
|
||||
|
||||
|
||||
return cb(null, recipientsList);
|
||||
});
|
||||
|
|
|
@ -295,6 +295,38 @@ describe('Email notifications', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should notify copayers when tx is confirmed if they are subscribed', function(done) {
|
||||
server.createAddress({}, function(err, address) {
|
||||
should.not.exist(err);
|
||||
|
||||
server.txConfirmationSubscribe({
|
||||
txid: '123'
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
// Simulate tx confirmation notification
|
||||
server._notify('TxConfirmation', {
|
||||
txid: '123',
|
||||
}, function(err) {
|
||||
setTimeout(function() {
|
||||
var calls = mailerStub.sendMail.getCalls();
|
||||
calls.length.should.equal(1);
|
||||
var email = calls[0].args[0];
|
||||
email.to.should.equal('copayer1@domain.com');
|
||||
email.from.should.equal('bws@dummy.net');
|
||||
email.subject.should.contain('Transaction confirmed');
|
||||
server.storage.fetchUnsentEmails(function(err, unsent) {
|
||||
should.not.exist(err);
|
||||
unsent.should.be.empty;
|
||||
done();
|
||||
});
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should notify each email address only once', function(done) {
|
||||
// Set same email address for copayer1 and copayer2
|
||||
server.savePreferences({
|
||||
|
|
Loading…
Reference in New Issue