diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-02-19 04:41:51 +0100 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-02-19 04:41:51 +0100 |
| commit | dd2f5af97f1ceccd049528743ca0e75ed2fe71c0 (patch) | |
| tree | c499219a8648e539f74ef1a3a2f66d4bfb112a71 /lib | |
| parent | 2e3218ddd0dd4cccf9038f1fc7b6565c7bad7595 (diff) | |
push frontend
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/okpush/apn.js | 2 | ||||
| -rw-r--r-- | lib/okpush/index.js | 6 | ||||
| -rw-r--r-- | lib/okpush/public/push.js | 5 | ||||
| -rw-r--r-- | lib/okpush/templates/index.liquid | 2 |
4 files changed, 7 insertions, 8 deletions
diff --git a/lib/okpush/apn.js b/lib/okpush/apn.js index 7506e08b..75322fae 100644 --- a/lib/okpush/apn.js +++ b/lib/okpush/apn.js @@ -11,7 +11,7 @@ function init (config) { apnProvider = new apn.Provider(config.apn.connection) } -function push (note) { +function push (channel, note) { db.getAllTokens(note, function(err, tokens){ if (err) { console.error("Error fetching devices:", err) diff --git a/lib/okpush/index.js b/lib/okpush/index.js index 6de59ac5..d696c350 100644 --- a/lib/okpush/index.js +++ b/lib/okpush/index.js @@ -99,10 +99,10 @@ function OKPush (options) { }) router.post('/send', bodyParser.urlencoded({ extended: false }), function (req, res) { - var key = req.body.key - var opt = options.config.notifications[key] + var channel = req.body.channel + var opt = options.config.notifications[channel] var note = apn.buildPayload(opt, options.config.bundleId) - // apn.push(note) + apn.push(channel, note) db.updateNotification(key, function(){ res.send(200) }) diff --git a/lib/okpush/public/push.js b/lib/okpush/public/push.js index d369c903..9a60a625 100644 --- a/lib/okpush/public/push.js +++ b/lib/okpush/public/push.js @@ -1,15 +1,14 @@ $(function(){ - var count = $(".device-count").data("count"); var confirm_msg = "This will send the notification {{key}} to {{count}} people. Click OK to confirm."; $(".notifications button").click(function(){ var $el = $(this) var data = $el.data() - var msg = confirm_msg.replace("{{key}}", data.key).replace("{{count}}", count) + var msg = confirm_msg.replace("{{key}}", data.key).replace("{{count}}", data.count) if (! confirm(msg)) return $.ajax({ type: "POST", url: "/_services/push/send", - data: { key: data.key }, + data: { channel: data.key }, success: function(){ alert("Push notification sent.") var now = new Date() diff --git a/lib/okpush/templates/index.liquid b/lib/okpush/templates/index.liquid index 36f688cc..12118fad 100644 --- a/lib/okpush/templates/index.liquid +++ b/lib/okpush/templates/index.liquid @@ -63,7 +63,7 @@ tr:nth-child(2n+1) { {{spec.count}} </td> <td> - <button data-key="{{name}}" class="btn">send</button> + <button data-key="{{name}}" data-count="{{spec.count}}" class="btn">send</button> </td> </tr> {% endfor %} |
