Merge pull request #699 from isocolsky/bch-unit
Use BCH unit on email & push notifications
This commit is contained in:
commit
c6269a39a5
|
@ -105,7 +105,12 @@ Utils.formatAmount = function(satoshis, unit, opts) {
|
|||
toSatoshis: 1,
|
||||
maxDecimals: 0,
|
||||
minDecimals: 0,
|
||||
}
|
||||
},
|
||||
bch: {
|
||||
toSatoshis: 100000000,
|
||||
maxDecimals: 6,
|
||||
minDecimals: 2,
|
||||
},
|
||||
};
|
||||
|
||||
$.shouldBeNumber(satoshis);
|
||||
|
|
|
@ -11,6 +11,7 @@ var path = require('path');
|
|||
var nodemailer = require('nodemailer');
|
||||
|
||||
var Utils = require('./common/utils');
|
||||
var Defaults = require('./common/defaults');
|
||||
var Storage = require('./storage');
|
||||
var MessageBroker = require('./messagebroker');
|
||||
var Lock = require('./lock');
|
||||
|
@ -173,6 +174,9 @@ EmailService.prototype._applyTemplate = function(template, data, cb) {
|
|||
EmailService.prototype._getRecipientsList = function(notification, emailType, cb) {
|
||||
var self = this;
|
||||
|
||||
self.storage.fetchWallet(notification.walletId, function(err, wallet) {
|
||||
if (err) return cb(err);
|
||||
|
||||
self.storage.fetchPreferences(notification.walletId, null, function(err, preferences) {
|
||||
if (err) return cb(err);
|
||||
if (_.isEmpty(preferences)) return cb(null, []);
|
||||
|
@ -191,16 +195,24 @@ EmailService.prototype._getRecipientsList = function(notification, emailType, cb
|
|||
p.language = self.defaultLanguage;
|
||||
}
|
||||
|
||||
var unit;
|
||||
if (wallet.coin != Defaults.COIN) {
|
||||
unit = wallet.coin;
|
||||
} else {
|
||||
unit = p.unit || self.defaultUnit;
|
||||
}
|
||||
|
||||
return {
|
||||
copayerId: p.copayerId,
|
||||
emailAddress: p.email,
|
||||
language: p.language,
|
||||
unit: p.unit || self.defaultUnit,
|
||||
unit: unit,
|
||||
};
|
||||
}));
|
||||
|
||||
return cb(null, recipients);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
EmailService.prototype._getDataForTemplate = function(notification, recipient, cb) {
|
||||
|
@ -209,7 +221,8 @@ EmailService.prototype._getDataForTemplate = function(notification, recipient, c
|
|||
// TODO: Declare these in BWU
|
||||
var UNIT_LABELS = {
|
||||
btc: 'BTC',
|
||||
bit: 'bits'
|
||||
bit: 'bits',
|
||||
bch: 'BCH',
|
||||
};
|
||||
|
||||
var data = _.cloneDeep(notification.data);
|
||||
|
|
|
@ -9,6 +9,7 @@ var Storage = require('./storage');
|
|||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var Utils = require('./common/utils');
|
||||
var Defaults = require('./common/defaults');
|
||||
var Model = require('./model');
|
||||
var sjcl = require('sjcl');
|
||||
var log = require('npmlog');
|
||||
|
@ -198,6 +199,11 @@ PushNotificationsService.prototype._getRecipientsList = function(notification, n
|
|||
self.storage.fetchWallet(notification.walletId, function(err, wallet) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var unit;
|
||||
if (wallet.coin != Defaults.COIN) {
|
||||
unit = wallet.coin;
|
||||
}
|
||||
|
||||
self.storage.fetchPreferences(notification.walletId, null, function(err, preferences) {
|
||||
|
||||
if (err) log.error(err);
|
||||
|
@ -214,7 +220,7 @@ PushNotificationsService.prototype._getRecipientsList = function(notification, n
|
|||
return {
|
||||
copayerId: p.copayerId,
|
||||
language: p.language,
|
||||
unit: p.unit,
|
||||
unit: unit || p.unit || self.defaultUnit,
|
||||
};
|
||||
}));
|
||||
|
||||
|
@ -227,7 +233,7 @@ PushNotificationsService.prototype._getRecipientsList = function(notification, n
|
|||
return {
|
||||
copayerId: copayer.id,
|
||||
language: p.language || self.defaultLanguage,
|
||||
unit: p.unit || self.defaultUnit,
|
||||
unit: unit || p.unit || self.defaultUnit,
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
@ -275,7 +281,8 @@ PushNotificationsService.prototype._getDataForTemplate = function(notification,
|
|||
var self = this;
|
||||
var UNIT_LABELS = {
|
||||
btc: 'BTC',
|
||||
bit: 'bits'
|
||||
bit: 'bits',
|
||||
bch: 'BCH',
|
||||
};
|
||||
|
||||
var data = _.cloneDeep(notification.data);
|
||||
|
|
|
@ -110,6 +110,7 @@ describe('Push notifications', function() {
|
|||
calls.length.should.equal(1);
|
||||
args[0].body.notification.title.should.contain('New payment received');
|
||||
args[0].body.notification.body.should.contain('123,000');
|
||||
args[0].body.notification.body.should.contain('bits');
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue