summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/okpush/db.js10
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()
}