diff --git a/lib/model/notification.js b/lib/model/notification.js index 2cffa09..4e45c0f 100644 --- a/lib/model/notification.js +++ b/lib/model/notification.js @@ -37,6 +37,7 @@ Notification.create = function(opts) { x.id = _.padLeft(now, 14, '0') + _.padLeft(opts.ticker || 0, 4, '0'); x.type = opts.type || 'general'; x.data = opts.data; + x.walletId = opts.walletId; x.creatorId = opts.creatorId; return x; @@ -49,6 +50,7 @@ Notification.fromObj = function(obj) { x.id = obj.id; x.type = obj.type, x.data = obj.data; + x.walletId = obj.walletId; x.creatorId = obj.creatorId; return x; diff --git a/lib/server.js b/lib/server.js index 6a2ebaa..5c190f8 100644 --- a/lib/server.js +++ b/lib/server.js @@ -189,6 +189,7 @@ WalletService.prototype._notify = function(type, data) { data: data, ticker: this.notifyTicker++, creatorId: self.copayerId, + walletId: walletId, }); this.storage.storeNotification(walletId, n, function() { self._emit('notification', n); @@ -351,13 +352,13 @@ WalletService.prototype._getBlockExplorer = function(provider, network) { return this.blockExplorer; switch (provider) { - default:; + default: ; case 'insight': switch (network) { default: - case 'livenet': + case 'livenet': url = 'https://insight.bitpay.com:443'; - break; + break; case 'testnet': url = 'https://test-insight.bitpay.com:443' break; diff --git a/test/integration/server.js b/test/integration/server.js index c57b926..705827b 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -1611,6 +1611,7 @@ describe('Copay server', function() { should.not.exist(err); var last = _.last(notifications); last.type.should.equal('TxProposalFinallyAccepted'); + last.walletId.should.equal(wallet.id); last.creatorId.should.equal(wallet.copayers[1].id); last.data.txProposalId.should.equal(txp.id); done(); @@ -1869,6 +1870,9 @@ describe('Copay server', function() { should.not.exist(err); var types = _.pluck(notifications, 'type'); types.should.deep.equal(['NewTxProposal', 'NewTxProposal', 'NewTxProposal', 'NewAddress']); + var walletIds = _.uniq(_.pluck(notifications, 'walletId')); + walletIds.length.should.equal(1); + walletIds[0].should.equal(wallet.id); var creators = _.uniq(_.pluck(notifications, 'creatorId')); creators.length.should.equal(1); creators[0].should.equal(wallet.copayers[0].id);