diff --git a/lib/emailservice.js b/lib/emailservice.js index 2f4772e..7d5af8f 100644 --- a/lib/emailservice.js +++ b/lib/emailservice.js @@ -190,10 +190,21 @@ EmailService.prototype._getRecipientsList = function(notification, emailType, cb EmailService.prototype._getDataForTemplate = function(notification, recipient, cb) { var self = this; + // TODO: Declare these in BWU + var UNIT_LABELS = { + btc: 'BTC', + bit: 'bits' + }; + var data = _.cloneDeep(notification.data); data.subjectPrefix = _.trim(self.subjectPrefix) + ' '; if (data.amount) { - data.amount = WalletUtils.formatAmount(+data.amount, recipient.unit) + ' ' + recipient.unit; + try { + var unit = recipient.unit.toLowerCase(); + data.amount = WalletUtils.formatAmount(+data.amount, unit) + ' ' + UNIT_LABELS[unit]; + } catch (ex) { + return cb(new Error('Could not format amount', ex)); + } } self.storage.fetchWallet(notification.walletId, function(err, wallet) { if (err) return cb(err); diff --git a/package.json b/package.json index e9dd0bf..77f8221 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "bitcore-wallet-service", "description": "A service for Mutisig HD Bitcoin Wallets", "author": "BitPay Inc", - "version": "0.0.39", + "version": "0.0.40", "keywords": [ "bitcoin", "copay", diff --git a/test/integration/server.js b/test/integration/server.js index 8411e31..7c763d0 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -607,14 +607,14 @@ describe('Wallet service', function() { spanish.from.should.equal('bws@dummy.net'); spanish.subject.should.contain('Nuevo pago recibido'); spanish.text.should.contain(wallet.name); - spanish.text.should.contain('0.123 btc'); + spanish.text.should.contain('0.123 BTC'); var english = _.find(emails, { to: 'copayer2@domain.com' }); english.from.should.equal('bws@dummy.net'); english.subject.should.contain('New payment received'); english.text.should.contain(wallet.name); - english.text.should.contain('123,000 bit'); + english.text.should.contain('123,000 bits'); done(); }, 100); });