summaryrefslogtreecommitdiff
path: root/lib/okpush/index.js
diff options
context:
space:
mode:
authorstone <jules+okfprojz@okfoc.us>2017-09-23 16:18:44 -0400
committerstone <jules+okfprojz@okfoc.us>2017-09-23 16:18:44 -0400
commit9fef3483d9c3b2e5e3508b8e5bb5ed080e65ca93 (patch)
tree87657d6847f71c0c82369f2eaf9da498e9e55136 /lib/okpush/index.js
parent20544c056ad5e8a03ce61061028194a4ce501a76 (diff)
parent709af63b290214b79271d96518e2ed51468e09f3 (diff)
Merge branch 'cms' of ghghgh.us:stone-island into cms
Diffstat (limited to 'lib/okpush/index.js')
-rw-r--r--lib/okpush/index.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/okpush/index.js b/lib/okpush/index.js
index 49fc5363..a0211bed 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)
})
@@ -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)
})