correctly assign copayerId to notification
This commit is contained in:
parent
0376768144
commit
4fc8faa483
|
@ -182,13 +182,15 @@ WalletService.prototype._notify = function(type, data) {
|
|||
log.debug('Notification', type, data);
|
||||
|
||||
var walletId = self.walletId || data.walletId;
|
||||
var copayerId = self.copayerId || data.copayerId;
|
||||
|
||||
$.checkState(walletId);
|
||||
|
||||
var n = Notification.create({
|
||||
type: type,
|
||||
data: data,
|
||||
ticker: this.notifyTicker++,
|
||||
creatorId: self.copayerId,
|
||||
creatorId: copayerId,
|
||||
walletId: walletId,
|
||||
});
|
||||
this.storage.storeNotification(walletId, n, function() {
|
||||
|
|
|
@ -30,6 +30,9 @@ WsApp.start = function(server) {
|
|||
|
||||
WalletService.onNotification(function(serviceInstance, args) {
|
||||
var room = serviceInstance.walletId || args.walletId;
|
||||
console.log('*** [wsapp.js ln33] args:', args); // TODO
|
||||
console.log('*** [wsapp.js ln33] room:', room); // TODO
|
||||
|
||||
if (room) {
|
||||
io.to(room).emit('notification', args);
|
||||
}
|
||||
|
|
|
@ -1908,6 +1908,19 @@ describe('Copay server', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should contain walletId & creatorId on NewCopayer', function(done) {
|
||||
server.getNotifications({
|
||||
minTs: 0,
|
||||
}, function(err, notifications) {
|
||||
should.not.exist(err);
|
||||
var newCopayer = notifications[0];
|
||||
newCopayer.type.should.equal('NewCopayer');
|
||||
newCopayer.walletId.should.equal(wallet.id);
|
||||
newCopayer.creatorId.should.equal(wallet.copayers[0].id);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should notify sign and acceptance', function(done) {
|
||||
server.getPendingTxs({}, function(err, txs) {
|
||||
helpers.stubBroadcastFail();
|
||||
|
|
Loading…
Reference in New Issue