summaryrefslogtreecommitdiff
path: root/lib/okpush/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/okpush/index.js')
-rw-r--r--lib/okpush/index.js26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/okpush/index.js b/lib/okpush/index.js
index cf2e928f..08ab15ae 100644
--- a/lib/okpush/index.js
+++ b/lib/okpush/index.js
@@ -46,6 +46,7 @@ function OKPush (options) {
var templates = {}
templates['index'] = templateProvider.getTemplate('index')
+ templates['new'] = templateProvider.getTemplate('new')
apn.init(config)
db.init(config)
@@ -92,8 +93,14 @@ function OKPush (options) {
})
})
+ router.get('/new', function (req, res) {
+ templates['new'].render(data).then(function(rendered) {
+ res.send(rendered);
+ }).fail(error(req, res, 500))
+ })
+
router.get('/list', function(req, res){
- db.getAllTokens("hub", function(err, hubz){
+ db.getAllTokens('hub', function(err, hubz){
res.json(hubz)
})
})
@@ -108,6 +115,23 @@ function OKPush (options) {
})
})
+ router.post('/custom', bodyParser.urlencoded({ extended: false }), function (req, res) {
+ var message = req.body.message
+ var url = req.body.url
+ if (! message || ! url) {
+ return res.sendStatus(500)
+ }
+ var opt = {
+ alert: message,
+ payload: { 'url': url },
+ }
+ var note = apn.buildPayload(opt, options.config.bundleId)
+ apn.push('hub', note)
+ db.addNotification(channel, function(){
+ res.sendStatus(200)
+ })
+ })
+
// should work without middleware
router.post('/add', bodyParser.urlencoded({ extended: false }), function (req, res) {
console.log(req.body)