diff --git a/lib/server.js b/lib/server.js index 090d1c9..4fcc19a 100644 --- a/lib/server.js +++ b/lib/server.js @@ -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() { diff --git a/lib/wsapp.js b/lib/wsapp.js index 8196e03..dd382b2 100644 --- a/lib/wsapp.js +++ b/lib/wsapp.js @@ -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); } diff --git a/test/integration/server.js b/test/integration/server.js index fa02405..b3d1c30 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -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();