Browse Source

add creator to notifications

activeAddress
Ivan Socolsky 10 years ago
parent
commit
43de1e458c
  1. 2
      lib/model/notification.js
  2. 1
      lib/server.js
  3. 10
      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.id = _.padLeft(now, 14, '0') + _.padLeft(opts.ticker || 0, 4, '0');
x.type = opts.type || 'general'; x.type = opts.type || 'general';
x.data = opts.data; x.data = opts.data;
x.creatorId = opts.creatorId;
return x; return x;
}; };
@ -48,6 +49,7 @@ Notification.fromObj = function(obj) {
x.id = obj.id; x.id = obj.id;
x.type = obj.type, x.type = obj.type,
x.data = obj.data; x.data = obj.data;
x.creatorId = obj.creatorId;
return x; return x;
}; };

1
lib/server.js

@ -188,6 +188,7 @@ WalletService.prototype._notify = function(type, data) {
type: type, type: type,
data: data, data: data,
ticker: this.notifyTicker++, ticker: this.notifyTicker++,
creatorId: self.copayerId,
}); });
this.storage.storeNotification(walletId, n, function() { this.storage.storeNotification(walletId, n, function() {
self._emit('notification', n); self._emit('notification', n);

10
test/integration/server.js

@ -1611,6 +1611,7 @@ describe('Copay server', function() {
should.not.exist(err); should.not.exist(err);
var last = _.last(notifications); var last = _.last(notifications);
last.type.should.equal('TxProposalFinallyAccepted'); last.type.should.equal('TxProposalFinallyAccepted');
last.creatorId.should.equal(wallet.copayers[1].id);
last.data.txProposalId.should.equal(txp.id); last.data.txProposalId.should.equal(txp.id);
done(); done();
}); });
@ -1868,6 +1869,9 @@ describe('Copay server', function() {
should.not.exist(err); should.not.exist(err);
var types = _.pluck(notifications, 'type'); var types = _.pluck(notifications, 'type');
types.should.deep.equal(['NewTxProposal', 'NewTxProposal', 'NewTxProposal', 'NewAddress']); types.should.deep.equal(['NewTxProposal', 'NewTxProposal', 'NewTxProposal', 'NewAddress']);
var creators = _.uniq(_.pluck(notifications, 'creatorId'));
creators.length.should.equal(1);
creators[0].should.equal(wallet.copayers[0].id);
done(); done();
}); });
}); });
@ -1964,9 +1968,9 @@ describe('Copay server', function() {
var types = _.pluck(notifications, 'type'); var types = _.pluck(notifications, 'type');
types.should.deep.equal(['NewOutgoingTx', 'TxProposalFinallyAccepted', 'TxProposalAcceptedBy']); types.should.deep.equal(['NewOutgoingTx', 'TxProposalFinallyAccepted', 'TxProposalAcceptedBy']);
// Check also events // Check also events
server._emit.getCall(0).args[0].type.should.equal('TxProposalAcceptedBy'); server._emit.getCall(0).args[1].type.should.equal('TxProposalAcceptedBy');
server._emit.getCall(1).args[0].type.should.equal('TxProposalFinallyAccepted');; server._emit.getCall(1).args[1].type.should.equal('TxProposalFinallyAccepted');;
server._emit.getCall(2).args[0].type.should.equal('NewOutgoingTx'); server._emit.getCall(2).args[1].type.should.equal('NewOutgoingTx');
done(); done();
}); });

Loading…
Cancel
Save