diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-10-06 14:46:54 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-10-06 14:46:54 -0400 |
| commit | c8c0b465d9796b526d268ea0e641fd7ba00e44bb (patch) | |
| tree | 5887519533426d0a4ac58c090f593e5ece0611b7 /examples/lib/okpush/index.js | |
| parent | f8bbee2634329595711d33ae82923f23a3ddb7fc (diff) | |
displaying list of notifications, slight css tweaks
Diffstat (limited to 'examples/lib/okpush/index.js')
| -rw-r--r-- | examples/lib/okpush/index.js | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/examples/lib/okpush/index.js b/examples/lib/okpush/index.js index d77eb8a..3ff8bb5 100644 --- a/examples/lib/okpush/index.js +++ b/examples/lib/okpush/index.js @@ -46,23 +46,42 @@ function OKPush (options) { apn.init(config) db.init(config) -// router.use('/admin/', passport.initialize()) -// router.all('/admin/(:path*)?', passport.authenticate('digest', { -// session: false -// })) + router.use('/admin/', passport.initialize()) + // monkeypatch because of this app.use(router) shit.. obnoxious + router.all('/admin/(:path*)?', function (req, res, next) { + // req.url = "/_services/push" + req.url + req.newUrl = req.url + req.url = req.originalUrl + next() + }) + router.all('/admin/(:path*)?', passport.authenticate('digest', { + session: false + })) + router.all('/admin/(:path*)?', function (req, res, next) { + req.url = req.newUrl + next() + }) + // pass in admin middleware! - router.get('/admin/', function (req, res) { - var data = { - meta: meta, - notifications: config.notifications, - } - templates['index'].render(data).then(function(rendered) { - res.send(rendered); - }).fail(error(req, res, 500)) + router.get('/admin', function (req, res) { + db.getNotifications(function(err, notes){ + var data = { + meta: meta, + notifications: config.notifications, + } + notes.forEach(function(note){ + if (note.key in data.notifications) { + data.notifications[ note.key ].last_push = note.last_push + } + }) + templates['index'].render(data).then(function(rendered) { + res.send(rendered); + }).fail(error(req, res, 500)) + }) }) - router.post('/send', function (req, res) { + router.post('/admin/send', function (req, res) { var key = req.body.key var opt = options.config.notifications[key] var note = apn.buildPayload(opt, options.config.bundleId) |
