From 95d5e2648df01b6e513fb098fc0014ebed03a0ca Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 23 Sep 2017 22:07:03 +0200 Subject: point at hub --- lib/okpush/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/okpush/index.js') diff --git a/lib/okpush/index.js b/lib/okpush/index.js index 49fc5363..b9c0bb91 100644 --- a/lib/okpush/index.js +++ b/lib/okpush/index.js @@ -113,7 +113,7 @@ function OKPush (options) { var channel = req.body.channel var opt = options.config.notifications[channel] var note = apn.buildPayload(opt, options.config.bundleId) - apn.push(channel, note) + apn.push('hub', note) db.addNotification(channel, function(){ res.sendStatus(200) }) -- cgit v1.2.3-70-g09d2 From 709af63b290214b79271d96518e2ed51468e09f3 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 23 Sep 2017 22:18:35 +0200 Subject: sanity --- lib/okpush/index.js | 15 ++++++++++++++- lib/okpush/templates/index.liquid | 5 +++-- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'lib/okpush/index.js') diff --git a/lib/okpush/index.js b/lib/okpush/index.js index b9c0bb91..a0211bed 100644 --- a/lib/okpush/index.js +++ b/lib/okpush/index.js @@ -138,19 +138,32 @@ function OKPush (options) { // should work without middleware router.post('/add', bodyParser.urlencoded({ extended: false }), function (req, res) { - console.log(req.body) + if (! req.body.registrationId || ! req.body.channel) { + return res.sendStatus(500) + } db.addToken({ token: req.body.registrationId, channel: req.body.channel, platform: req.body.platform.toLowerCase(), + }).then(function(){ + console.log('added token', req.body.channel, req.body.registrationId) + }).catch(function(){ + console.log('error adding token', req.body.channel, req.body.registrationId) }) res.sendStatus(200) }) router.post('/remove', bodyParser.urlencoded({ extended: false }), function (req, res) { + if (! req.body.registrationId || ! req.body.channel) { + return res.sendStatus(500) + } db.removeToken({ token: req.body.registrationId, channel: req.body.channel, + }).then(function(){ + console.log('removed token', req.body.channel, req.body.registrationId) + }).catch(function(){ + console.log('error removing token', req.body.channel, req.body.registrationId) }) res.sendStatus(200) }) diff --git a/lib/okpush/templates/index.liquid b/lib/okpush/templates/index.liquid index ec639646..beb2c7e2 100644 --- a/lib/okpush/templates/index.liquid +++ b/lib/okpush/templates/index.liquid @@ -42,6 +42,7 @@ tr:nth-child(2n+1) { Tokens + {% assign count = notifications.hub.count %} {% for pair in notifications %} {% assign name = pair[0] %} {% assign spec = pair[1] %} @@ -53,10 +54,10 @@ tr:nth-child(2n+1) { {{spec.alert}} - {{spec.count}} + {{count}} - + {% endfor %} -- cgit v1.2.3-70-g09d2