Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/push/rescind.js
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | for (const row of fetchResult) { | ||||
for (const delivery of deliveries) { | for (const delivery of deliveries) { | ||||
if (delivery.iosID && delivery.iosDeviceTokens) { | if (delivery.iosID && delivery.iosDeviceTokens) { | ||||
// Old iOS | // Old iOS | ||||
const notification = prepareIOSNotification( | const notification = prepareIOSNotification( | ||||
delivery.iosID, | delivery.iosID, | ||||
row.unread_count, | row.unread_count, | ||||
threadID, | threadID, | ||||
); | ); | ||||
const targetedNotifications = delivery.iosDeviceTokens.map( | |||||
deviceToken => ({ deviceToken, notification }), | |||||
); | |||||
deliveryPromises[id] = apnPush({ | deliveryPromises[id] = apnPush({ | ||||
notification, | targetedNotifications, | ||||
deviceTokens: delivery.iosDeviceTokens, | |||||
platformDetails: { platform: 'ios' }, | platformDetails: { platform: 'ios' }, | ||||
}); | }); | ||||
} else if (delivery.androidID) { | } else if (delivery.androidID) { | ||||
// Old Android | // Old Android | ||||
const notification = prepareAndroidNotification( | const notification = prepareAndroidNotification( | ||||
row.collapse_key ? row.collapse_key : id, | row.collapse_key ? row.collapse_key : id, | ||||
row.unread_count, | row.unread_count, | ||||
threadID, | threadID, | ||||
); | ); | ||||
deliveryPromises[id] = fcmPush({ | deliveryPromises[id] = fcmPush({ | ||||
notification, | notification, | ||||
deviceTokens: delivery.androidDeviceTokens, | deviceTokens: delivery.androidDeviceTokens, | ||||
codeVersion: null, | codeVersion: null, | ||||
}); | }); | ||||
} else if (delivery.deviceType === 'ios') { | } else if (delivery.deviceType === 'ios') { | ||||
// New iOS | // New iOS | ||||
const { iosID, deviceTokens, codeVersion } = delivery; | const { iosID, deviceTokens, codeVersion } = delivery; | ||||
const notification = prepareIOSNotification( | const notification = prepareIOSNotification( | ||||
iosID, | iosID, | ||||
row.unread_count, | row.unread_count, | ||||
threadID, | threadID, | ||||
codeVersion, | codeVersion, | ||||
); | ); | ||||
deliveryPromises[id] = apnPush({ | const targetedNotifications = deviceTokens.map(deviceToken => ({ | ||||
deviceToken, | |||||
notification, | notification, | ||||
deviceTokens, | })); | ||||
deliveryPromises[id] = apnPush({ | |||||
targetedNotifications, | |||||
platformDetails: { platform: 'ios', codeVersion }, | platformDetails: { platform: 'ios', codeVersion }, | ||||
}); | }); | ||||
} else if (delivery.deviceType === 'android') { | } else if (delivery.deviceType === 'android') { | ||||
// New Android | // New Android | ||||
const { deviceTokens, codeVersion } = delivery; | const { deviceTokens, codeVersion } = delivery; | ||||
const notification = prepareAndroidNotification( | const notification = prepareAndroidNotification( | ||||
row.collapse_key ? row.collapse_key : id, | row.collapse_key ? row.collapse_key : id, | ||||
row.unread_count, | row.unread_count, | ||||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |