Browse Source

add walletId to notification model

activeAddress
Ivan Socolsky 10 years ago
parent
commit
ef45a97e5b
  1. 2
      lib/model/notification.js
  2. 7
      lib/server.js
  3. 4
      test/integration/server.js

2
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;

7
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;

4
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);

Loading…
Cancel
Save