aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/middleware
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/server/middleware')
-rw-r--r--vnext/server/middleware/event.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/vnext/server/middleware/event.js b/vnext/server/middleware/event.js
index 59f36950..8280f32b 100644
--- a/vnext/server/middleware/event.js
+++ b/vnext/server/middleware/event.js
@@ -24,12 +24,12 @@ function processMessageEvent(msg) {
params.mid = msg.mid
}
subscribers(new URLSearchParams(JSON.parse(JSON.stringify(params)))).then(users => {
- users.forEach(user => {
+ return users.map(user => {
log(`${user.uname}: ${user.unreadCount}`)
let [sandboxTokens, productionTokens] = (user.tokens || [])
.filter(t => ['mpns', 'apns', 'fcm', 'web'].includes(t.type))
.map(t => t.type === 'web' ? JSON.parse(t.token) : t.token)
- .reduce((result, element, i) => {
+ .reduce((result, element) => {
allSandboxIds.includes(user.uid)
? result[0].push(element)
: result[1].push(element)
@@ -44,10 +44,14 @@ function processMessageEvent(msg) {
.filter(t => t.type === 'hcm')
.map(t => t.token)
log(`${user.uname}: ${hmsIds}`)
- send(msg, hmsIds).then(() => {
- // TODO: handle results
- }).catch(log)
+ return hmsIds
})
+ }).then(userHmsIds => {
+ userHmsIds.forEach(hmsIds => {
+ send(msg, hmsIds)
+ })
+ }).then(() => {
+ // TODO: handle results
}).catch(log)
}