Merge pull request #270 from isocolsky/fix/email_service
Fix/email service
This commit is contained in:
commit
a3d01f8988
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue