Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/push/send.js
Show First 20 Lines • Show All 231 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 shimmedNewRawMessageInfos = shimUnsupportedRawMessageInfos( | |||||
newRawMessageInfos, | |||||
{ platform: 'macos', codeVersion }, | |||||
); | |||||
const deliveryPromise = (async () => { | |||||
const notification = await prepareAPNsNotification( | |||||
allMessageInfos, | |||||
shimmedNewRawMessageInfos, | |||||
threadInfo, | |||||
notifInfo.collapseKey, | |||||
badgeOnly, | |||||
unreadCounts[userID], | |||||
{ platform: 'macos', codeVersion }, | |||||
); | |||||
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 260 Lines • ▼ Show 20 Lines | ): Promise<apn.Notification> { | ||||
const uniqueID = uuidv4(); | const uniqueID = uuidv4(); | ||||
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, | ||||
getENSNames, | getENSNames, | ||||
); | ); | ||||
if (!badgeOnly) { | if (!badgeOnly && platformDetails.platform !== 'macos') { | ||||
ashoat: Can you add a code comment explaining why we don't include `body` or `sounds` for 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 412 Lines • Show Last 20 Lines |
Can you add a code comment explaining why we don't include body or sounds for macOS?