diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-03-13 02:11:51 +0100 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-03-13 02:11:51 +0100 |
| commit | 7361873eec849daf7a2e367f05c91782c7e265ad (patch) | |
| tree | 40e32fb35c6836b508516f4d90e986de32d38038 /lib | |
| parent | 7cb6b91f674108a73cde7d641b0949e21efdf3b8 (diff) | |
fix push token invocation
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/okpush/apn.js | 13 | ||||
| -rw-r--r-- | lib/okpush/db.js | 6 |
2 files changed, 10 insertions, 9 deletions
diff --git a/lib/okpush/apn.js b/lib/okpush/apn.js index 14de7ac8..05eaa1f5 100644 --- a/lib/okpush/apn.js +++ b/lib/okpush/apn.js @@ -3,12 +3,13 @@ var apn = require('apn') var db = require('./db') var apnProvider, apnFeedback -function init (config) { - var apn_config = config.production ? config.apn_production : config.apn_development - config.apn = apn_config - config.apn.connection.key = apn_config.key - config.apn.connection.cert = apn_config.cert - apnProvider = new apn.Provider(config.apn.connection) +function init (data) { + var apn_config = data.production ? config.apn_production : config.apn_development + config = {} + config.key = apn_config.key + config.cert = apn_config.cert + config.production = data.production + apnProvider = new apn.Provider(config) } function push (channel, note) { diff --git a/lib/okpush/db.js b/lib/okpush/db.js index 09a2c3aa..001c06b5 100644 --- a/lib/okpush/db.js +++ b/lib/okpush/db.js @@ -67,7 +67,7 @@ function addToken (data) { return new PushToken(data).save() } function getAllIOSTokens (channel, cb) { - PushToken.find({ channel: channel, platform: 'ios' }, function (err, items) { + PushToken.distinct("token", { channel: channel, platform: 'ios' }, function (err, items) { if (err) return cb(err, null) var items = _.map(items, function (item) { return item.token @@ -76,7 +76,7 @@ function getAllIOSTokens (channel, cb) { }) } function getAllAndroidTokens (channel, cb) { - PushToken.find({ channel: channel, platform: 'android' }, function (err, items) { + PushToken.distinct("token", { channel: channel, platform: 'android' }, function (err, items) { if (err) return cb(err, null) var items = _.map(items, function (item) { return item.token @@ -85,7 +85,7 @@ function getAllAndroidTokens (channel, cb) { }) } function getAllTokens (channel, cb) { - PushToken.find({ channel: channel }, function (err, items) { + PushToken.distinct("token", { channel: channel }, function (err, items) { if (err) return cb(err, null) var items = _.map(items, function (item) { return _.pick(item, ['platform', 'token']) |
