Browse Source

include amount in incomingTx email

activeAddress
Ivan Socolsky 10 years ago
parent
commit
26cb34e2b7
  1. 4
      lib/emailservice.js
  2. 2
      lib/templates/new_incoming_tx.plain
  3. 5
      test/integration/server.js

4
lib/emailservice.js

@ -8,6 +8,7 @@ log.debug = log.verbose;
var fs = require('fs');
var nodemailer = require('nodemailer');
var WalletUtils = require('bitcore-wallet-utils');
var Storage = require('./storage');
var MessageBroker = require('./messagebroker');
var Lock = require('./lock');
@ -140,6 +141,9 @@ EmailService.prototype._getDataForTemplate = function(notification, cb) {
var data = _.cloneDeep(notification.data);
data.subjectPrefix = _.trim(self.subjectPrefix) + ' ';
if (data.amount) {
data.amount = WalletUtils.formatAmount(+data.amount, 'bit') + ' bits';
}
self.storage.fetchWallet(notification.walletId, function(err, wallet) {
if (err) return cb(err);
data.walletId = wallet.id;

2
lib/templates/new_incoming_tx.plain

@ -1,2 +1,2 @@
<%= subjectPrefix %>New payment received
A Payment has been received into your wallet <%= walletName %>.
A payment of <%= amount %> has been received into your wallet <%= walletName %>.

5
test/integration/server.js

@ -329,7 +329,7 @@ describe('Wallet service', function() {
});
});
it('should notify copayers of incoming txs', function(done) {
it.only('should notify copayers of incoming txs', function(done) {
server.createAddress({}, function(err, address) {
should.not.exist(err);
@ -337,7 +337,7 @@ describe('Wallet service', function() {
server._notify('NewIncomingTx', {
txid: '999',
address: address,
amount: 123,
amount: 12300000,
}, function(err) {
setTimeout(function() {
var calls = mailerStub.sendMail.getCalls();
@ -350,6 +350,7 @@ describe('Wallet service', function() {
one.from.should.equal('bws@dummy.net');
one.subject.should.contain('New payment received');
one.text.should.contain(wallet.name);
one.text.should.contain('123,000');
server.storage.fetchUnsentEmails(function(err, unsent) {
should.not.exist(err);
unsent.should.be.empty;

Loading…
Cancel
Save