correctly assign copayerId to notification

This commit is contained in:
Ivan Socolsky 2015-03-30 11:46:00 -03:00
parent 0376768144
commit 4fc8faa483
3 changed files with 19 additions and 1 deletions

View File

@ -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() {

View File

@ -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);
}

View File

@ -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();