From 9d4afc4402d9ac3fc5e0f4e5f3738781ce4d7f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Mon, 18 Jan 2016 16:28:11 -0300 Subject: [PATCH 1/2] fix user field --- lib/server.js | 4 ++-- test/integration/server.js | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/server.js b/lib/server.js index fbb0dc7..e4bb3ef 100644 --- a/lib/server.js +++ b/lib/server.js @@ -2433,7 +2433,7 @@ WalletService.prototype.pushNotificationsSubscribe = function(opts, cb) { var self = this; - opts.user = self.walletId + '$' + self.copayerId + '$' + opts.token; + opts.user = self.walletId + '$' + self.copayerId; request({ url: config.pushNotificationsOpts.pushServerUrl + '/subscribe', @@ -2453,7 +2453,7 @@ WalletService.prototype.pushNotificationsUnsubscribe = function(token, cb) { method: 'POST', json: true, body: { - user: self.walletId + '$' + self.copayerId + '$' + token + user: self.walletId + '$' + self.copayerId } }, function(err, response) { return cb(err, response); diff --git a/test/integration/server.js b/test/integration/server.js index ff62e38..63a2de3 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -5478,7 +5478,6 @@ describe('Wallet service', function() { }); args[0].body.user.should.contain(wallet.copayers[0].id); args[0].body.user.should.contain(wallet.id); - args[0].body.user.should.contain('DEVICE_TOKEN'); done(); }); }); @@ -5498,7 +5497,6 @@ describe('Wallet service', function() { args[0].body.user.should.contain(wallet.copayers[0].id); args[0].body.user.should.contain(wallet.id); - args[0].body.user.should.contain('DEVICE_TOKEN'); done(); }); }); From 965a859cbcc8a9685a4b69094de45450f5243236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Mon, 18 Jan 2016 17:37:40 -0300 Subject: [PATCH 2/2] delete token variable --- lib/expressapp.js | 4 ++-- lib/server.js | 2 +- test/integration/server.js | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/expressapp.js b/lib/expressapp.js index af850fb..aefc0a2 100644 --- a/lib/expressapp.js +++ b/lib/expressapp.js @@ -527,9 +527,9 @@ ExpressApp.prototype.start = function(opts, cb) { }); }); - router.delete('/v1/pushnotifications/subscriptions/:token/', function(req, res) { + router.delete('/v1/pushnotifications/subscriptions/', function(req, res) { getServerWithAuth(req, res, function(server) { - server.pushNotificationsUnsubscribe(req.params['token'], function(err, response) { + server.pushNotificationsUnsubscribe(function(err, response) { if (err) return returnError(err, res, req); res.json(response); }); diff --git a/lib/server.js b/lib/server.js index e4bb3ef..9b731c1 100644 --- a/lib/server.js +++ b/lib/server.js @@ -2445,7 +2445,7 @@ WalletService.prototype.pushNotificationsSubscribe = function(opts, cb) { }); }; -WalletService.prototype.pushNotificationsUnsubscribe = function(token, cb) { +WalletService.prototype.pushNotificationsUnsubscribe = function(cb) { var self = this; request({ diff --git a/test/integration/server.js b/test/integration/server.js index 63a2de3..b245558 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -5478,6 +5478,7 @@ describe('Wallet service', function() { }); args[0].body.user.should.contain(wallet.copayers[0].id); args[0].body.user.should.contain(wallet.id); + args[0].body.token.should.contain('DEVICE_TOKEN'); done(); }); }); @@ -5487,7 +5488,7 @@ describe('Wallet service', function() { request.yields(); helpers.getAuthServer(wallet.copayers[0].id, function(server) { should.exist(server); - server.pushNotificationsUnsubscribe('DEVICE_TOKEN', function(err, response) { + server.pushNotificationsUnsubscribe(function(err, response) { should.not.exist(err); var calls = request.getCalls(); calls.length.should.equal(1);