summaryrefslogtreecommitdiff
path: root/lib/okpush/index.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-09-23 22:18:35 +0200
committerJules Laplace <julescarbon@gmail.com>2017-09-23 22:18:35 +0200
commit709af63b290214b79271d96518e2ed51468e09f3 (patch)
treed5f2c237912268e9cca6ad9fa79ad46082faf30f /lib/okpush/index.js
parent95d5e2648df01b6e513fb098fc0014ebed03a0ca (diff)
sanity
Diffstat (limited to 'lib/okpush/index.js')
-rw-r--r--lib/okpush/index.js15
1 files changed, 14 insertions, 1 deletions
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)
})