Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/push/rescind.js
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | for (const delivery of deliveries) { | ||||
const notification = prepareIOSNotification( | const notification = prepareIOSNotification( | ||||
delivery.iosID, | delivery.iosID, | ||||
row.unread_count, | row.unread_count, | ||||
threadID, | threadID, | ||||
); | ); | ||||
deliveryPromises[id] = apnPush({ | deliveryPromises[id] = apnPush({ | ||||
notification, | notification, | ||||
deviceTokens: delivery.iosDeviceTokens, | deviceTokens: delivery.iosDeviceTokens, | ||||
codeVersion: null, | 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, | ||||
); | ); | ||||
Show All 9 Lines | for (const delivery of deliveries) { | ||||
iosID, | iosID, | ||||
row.unread_count, | row.unread_count, | ||||
threadID, | threadID, | ||||
codeVersion, | codeVersion, | ||||
); | ); | ||||
deliveryPromises[id] = apnPush({ | deliveryPromises[id] = apnPush({ | ||||
notification, | notification, | ||||
deviceTokens, | deviceTokens, | ||||
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, | ||||
threadID, | threadID, | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
function prepareIOSNotification( | function prepareIOSNotification( | ||||
iosID: string, | iosID: string, | ||||
unreadCount: number, | unreadCount: number, | ||||
threadID: string, | threadID: string, | ||||
codeVersion: ?number, | codeVersion: ?number, | ||||
): apn.Notification { | ): apn.Notification { | ||||
const notification = new apn.Notification(); | const notification = new apn.Notification(); | ||||
notification.contentAvailable = true; | notification.contentAvailable = true; | ||||
notification.topic = getAPNsNotificationTopic(codeVersion); | notification.topic = getAPNsNotificationTopic({ | ||||
platform: 'ios', | |||||
codeVersion: codeVersion ?? undefined, | |||||
}); | |||||
notification.priority = 5; | notification.priority = 5; | ||||
notification.pushType = 'background'; | notification.pushType = 'background'; | ||||
notification.payload = | notification.payload = | ||||
codeVersion && codeVersion > 135 | codeVersion && codeVersion > 135 | ||||
? { | ? { | ||||
backgroundNotifType: 'CLEAR', | backgroundNotifType: 'CLEAR', | ||||
notificationId: iosID, | notificationId: iosID, | ||||
setUnreadStatus: true, | setUnreadStatus: true, | ||||
Show All 28 Lines |