diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-03-13 02:30:28 +0100 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-03-13 02:30:28 +0100 |
| commit | 37a2226aec786a624acd8ed3f8b450ad033d8dc6 (patch) | |
| tree | 2d6478fb0bfa3d65292858768037c9e5e03664b5 /lib | |
| parent | b5d965c13a608eddaf752c487736ac94514b98ef (diff) | |
token count
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/okpush/db.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/okpush/db.js b/lib/okpush/db.js index 001c06b5..1a2099d0 100644 --- a/lib/okpush/db.js +++ b/lib/okpush/db.js @@ -68,7 +68,7 @@ function addToken (data) { } function getAllIOSTokens (channel, cb) { PushToken.distinct("token", { channel: channel, platform: 'ios' }, function (err, items) { - if (err) return cb(err, null) + if (err) return cb(err, []) var items = _.map(items, function (item) { return item.token }) @@ -77,7 +77,7 @@ function getAllIOSTokens (channel, cb) { } function getAllAndroidTokens (channel, cb) { PushToken.distinct("token", { channel: channel, platform: 'android' }, function (err, items) { - if (err) return cb(err, null) + if (err) return cb(err, []) var items = _.map(items, function (item) { return item.token }) @@ -86,7 +86,7 @@ function getAllAndroidTokens (channel, cb) { } function getAllTokens (channel, cb) { PushToken.distinct("token", { channel: channel }, function (err, items) { - if (err) return cb(err, null) + if (err) return cb(err, []) var items = _.map(items, function (item) { return _.pick(item, ['platform', 'token']) }) @@ -101,8 +101,8 @@ function getDeviceCount (channels, cb) { get_next() function get_next() { var channel = channels.pop() - PushToken.count({ channel: channel }, function(err, count){ - countz[channel] = count + PushToken.distinct("token", { channel: channel }, function(err, tokens){ + countz[channel] = tokens.length if (channels.length) { return get_next() } |
