diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-09-21 15:49:50 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-09-21 15:49:50 +0200 |
| commit | e14276957d196223b873419d5e80dd5c8ead945c (patch) | |
| tree | 49bdc21590c60485b7c3ba7f3dff2e4575e3085f /lib | |
| parent | e6c2b28c9824cae592c59c4838d12ae98fb27f9e (diff) | |
endpoint
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/okpush/index.js | 23 | ||||
| -rw-r--r-- | lib/okpush/public/push.js | 4 | ||||
| -rw-r--r-- | lib/okpush/templates/new.liquid | 4 |
3 files changed, 26 insertions, 5 deletions
diff --git a/lib/okpush/index.js b/lib/okpush/index.js index 36588aa2..391f64f9 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,20 @@ function OKPush (options) { }) }) + router.post('/custom', bodyParser.urlencoded({ extended: false }), function (req, res) { + var message = req.body.message + var url = req.body.url + 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) { db.addToken({ diff --git a/lib/okpush/public/push.js b/lib/okpush/public/push.js index 06588327..ca32fa98 100644 --- a/lib/okpush/public/push.js +++ b/lib/okpush/public/push.js @@ -31,7 +31,7 @@ $(function(){ $('#custom').submit(function(e){ e.preventDefault() var message = $("#message").val().trim() - var dest = $("#dest").val() + var url = $("#url").val() var msg = "This will send this push notification to everyone. Click OK to confirm.\n\n" + message if (! confirm(msg)) return @@ -40,7 +40,7 @@ $(function(){ url: "/_services/push/custom", data: { message: message, - dest: dest, + url: url, }, success: function(){ alert("Push notification sent.") diff --git a/lib/okpush/templates/new.liquid b/lib/okpush/templates/new.liquid index 0393535c..b16d0ae0 100644 --- a/lib/okpush/templates/new.liquid +++ b/lib/okpush/templates/new.liquid @@ -21,8 +21,8 @@ </div> <div> - <label for='dest'>Destination</label> - <select id='dest' name='dest'> + <label for='url'>Destination</label> + <select id='url' name='url'> <option>/</option> <option selected>/store</option> <option>/hub</option> |
