Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/push/send.js
Show First 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | for (const notifInfo of usersToCollapsableNotifInfo[userID]) { | ||||
return await sendWebNotification(notification, [...deviceTokens], { | return await sendWebNotification(notification, [...deviceTokens], { | ||||
...notificationInfo, | ...notificationInfo, | ||||
codeVersion, | codeVersion, | ||||
}); | }); | ||||
})(); | })(); | ||||
deliveryPromises.push(deliveryPromise); | deliveryPromises.push(deliveryPromise); | ||||
} | } | ||||
} | } | ||||
const macosVersionsToTokens = byPlatform.get('macos'); | |||||
if (macosVersionsToTokens) { | |||||
for (const [codeVersion, deviceTokens] of macosVersionsToTokens) { | |||||
const platformDetails = { platform: 'macos', codeVersion }; | |||||
const shimmedNewRawMessageInfos = shimUnsupportedRawMessageInfos( | |||||
newRawMessageInfos, | |||||
platformDetails, | |||||
); | |||||
const deliveryPromise = (async () => { | |||||
const notification = await prepareAPNsNotification({ | |||||
allMessageInfos, | |||||
newRawMessageInfos: shimmedNewRawMessageInfos, | |||||
threadInfo, | |||||
collapseKey: notifInfo.collapseKey, | |||||
badgeOnly, | |||||
unreadCount: unreadCounts[userID], | |||||
platformDetails, | |||||
notifTargetUserInfo: { | |||||
id: userID, | |||||
username, | |||||
}, | |||||
}); | |||||
return await sendAPNsNotification( | |||||
'macos', | |||||
notification, | |||||
[...deviceTokens], | |||||
{ | |||||
...notificationInfo, | |||||
codeVersion, | |||||
}, | |||||
); | |||||
})(); | |||||
deliveryPromises.push(deliveryPromise); | |||||
} | |||||
} | |||||
for (const newMessageInfo of remainingNewMessageInfos) { | for (const newMessageInfo of remainingNewMessageInfos) { | ||||
const newDBID = dbIDs.shift(); | const newDBID = dbIDs.shift(); | ||||
invariant(newDBID, 'should have sufficient DB IDs'); | invariant(newDBID, 'should have sufficient DB IDs'); | ||||
const messageID = newMessageInfo.id; | const messageID = newMessageInfo.id; | ||||
invariant(messageID, 'RawMessageInfo.id should be set on server'); | invariant(messageID, 'RawMessageInfo.id should be set on server'); | ||||
notifications.set(newDBID, { | notifications.set(newDBID, { | ||||
dbID: newDBID, | dbID: newDBID, | ||||
▲ Show 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | ): Promise<apn.Notification> { | ||||
const notification = new apn.Notification(); | const notification = new apn.Notification(); | ||||
notification.topic = getAPNsNotificationTopic(platformDetails); | notification.topic = getAPNsNotificationTopic(platformDetails); | ||||
const { merged, ...rest } = await notifTextsForMessageInfo( | const { merged, ...rest } = await notifTextsForMessageInfo( | ||||
allMessageInfos, | allMessageInfos, | ||||
threadInfo, | threadInfo, | ||||
notifTargetUserInfo, | notifTargetUserInfo, | ||||
getENSNames, | getENSNames, | ||||
); | ); | ||||
if (!badgeOnly) { | |||||
// We don't include alert's body on macOS because we | |||||
// handle displaying the notification ourselves and | |||||
// we don't want macOS to display it automatically. | |||||
if (!badgeOnly && platformDetails.platform !== 'macos') { | |||||
notification.body = merged; | notification.body = merged; | ||||
notification.sound = 'default'; | notification.sound = 'default'; | ||||
} | } | ||||
notification.payload = { | notification.payload = { | ||||
...notification.payload, | ...notification.payload, | ||||
...rest, | ...rest, | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 429 Lines • Show Last 20 Lines |