Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/creators/message-creator.js
Show First 20 Lines • Show All 469 Lines • ▼ Show 20 Lines | for (const pair of perUserInfo) { | ||||
userPushInfoPromises[userID] = userPushInfoPromise; | userPushInfoPromises[userID] = userPushInfoPromise; | ||||
} | } | ||||
const latestMessages = flattenLatestMessagesPerUser(latestMessagesPerUser); | const latestMessages = flattenLatestMessagesPerUser(latestMessagesPerUser); | ||||
const [pushInfo] = await Promise.all([ | const [pushInfo] = await Promise.all([ | ||||
promiseAll(userPushInfoPromises), | promiseAll(userPushInfoPromises), | ||||
createReadStatusUpdates(latestMessages), | createReadStatusUpdates(latestMessages), | ||||
redisPublish(viewer, messageInfosPerUser, updatesForCurrentSession), | messageBrokerPublish(viewer, messageInfosPerUser, updatesForCurrentSession), | ||||
updateLatestMessages(latestMessages), | updateLatestMessages(latestMessages), | ||||
]); | ]); | ||||
await sendPushNotifs(_pickBy(Boolean)(pushInfo)); | await sendPushNotifs(_pickBy(Boolean)(pushInfo)); | ||||
} | } | ||||
async function redisPublish( | async function messageBrokerPublish( | ||||
viewer: Viewer, | viewer: Viewer, | ||||
messageInfosPerUser: { [userID: string]: $ReadOnlyArray<RawMessageInfo> }, | messageInfosPerUser: { [userID: string]: $ReadOnlyArray<RawMessageInfo> }, | ||||
updatesForCurrentSession: UpdatesForCurrentSession, | updatesForCurrentSession: UpdatesForCurrentSession, | ||||
) { | ) { | ||||
const avoidBroadcastingToCurrentSession = | const avoidBroadcastingToCurrentSession = | ||||
viewer.hasSessionInfo && updatesForCurrentSession !== 'broadcast'; | viewer.hasSessionInfo && updatesForCurrentSession !== 'broadcast'; | ||||
for (const userID in messageInfosPerUser) { | for (const userID in messageInfosPerUser) { | ||||
if (userID === viewer.userID && avoidBroadcastingToCurrentSession) { | if (userID === viewer.userID && avoidBroadcastingToCurrentSession) { | ||||
▲ Show 20 Lines • Show All 165 Lines • Show Last 20 Lines |