diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-10-06 13:20:23 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-10-06 13:20:23 -0400 |
| commit | f8bbee2634329595711d33ae82923f23a3ddb7fc (patch) | |
| tree | 50aedcdc2006eda324b59f8eaeb831fc13fd6eac /examples/lib/okpush/index.js | |
| parent | ef2cfac2c055cdfa3958374c68a8d0cfe4e4f046 (diff) | |
store notification last update in db
Diffstat (limited to 'examples/lib/okpush/index.js')
| -rw-r--r-- | examples/lib/okpush/index.js | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/examples/lib/okpush/index.js b/examples/lib/okpush/index.js index a39cd35..d77eb8a 100644 --- a/examples/lib/okpush/index.js +++ b/examples/lib/okpush/index.js @@ -8,8 +8,7 @@ var OKTemplate = require('../../../app/node_modules/oktemplate') var apn = require('./apn') var db = require('./db') -passport.use(new DigestStrategy({qop: 'auth'}, - function authenticate(username, done) { +passport.use(new DigestStrategy({qop: 'auth'}, function authenticate(username, done) { if (!process.env.OK_USER || !process.env.OK_PASS) { return done(new Error('No user or pass configured on server')) } else { @@ -52,12 +51,6 @@ function OKPush (options) { // session: false // })) - var notifications = {} - Object.keys(options.config.notifications).forEach(function(key){ - var opt = options.config.notifications[key] - var note = apn.buildPayload(opt, options.config.bundleId) - }) - // pass in admin middleware! router.get('/admin/', function (req, res) { var data = { @@ -70,7 +63,13 @@ function OKPush (options) { }) router.post('/send', function (req, res) { - // add a key + var key = req.body.key + var opt = options.config.notifications[key] + var note = apn.buildPayload(opt, options.config.bundleId) + // apn.push(note) + db.updateNotification(key, function(){ + res.send(200) + }) }) // should work without middleware |
