Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/push/rescind.js
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | for (const row of fetchResult) { | ||||
notifInfo[id] = { | notifInfo[id] = { | ||||
userID: row.user.toString(), | userID: row.user.toString(), | ||||
threadID, | threadID, | ||||
messageID: row.message.toString(), | messageID: row.message.toString(), | ||||
}; | }; | ||||
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 notifications = [ | ||||
delivery.iosID, | prepareIOSNotification(delivery.iosID, row.unread_count, threadID), | ||||
row.unread_count, | ]; | ||||
threadID, | |||||
); | |||||
deliveryPromises[id] = apnPush({ | deliveryPromises[id] = apnPush({ | ||||
notification, | notifications, | ||||
deviceTokens: delivery.iosDeviceTokens, | 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 notifications = [ | ||||
prepareIOSNotification( | |||||
iosID, | iosID, | ||||
row.unread_count, | row.unread_count, | ||||
threadID, | threadID, | ||||
codeVersion, | codeVersion, | ||||
); | ), | ||||
]; | |||||
deliveryPromises[id] = apnPush({ | deliveryPromises[id] = apnPush({ | ||||
notification, | notifications, | ||||
deviceTokens, | deviceTokens, | ||||
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, | ||||
▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines |