Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2836985
D12398.id41215.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
19 KB
Referenced Files
None
Subscribers
None
D12398.id41215.diff
View Options
diff --git a/keyserver/src/push/crypto.js b/keyserver/src/push/crypto.js
--- a/keyserver/src/push/crypto.js
+++ b/keyserver/src/push/crypto.js
@@ -132,8 +132,8 @@
notificationSizeValidator?: apn.Notification => boolean,
): Promise<
$ReadOnlyArray<{
- +cookieID: string,
- +deviceToken: string,
+ +cryptoID: string,
+ +deliveryID: string,
+notification: apn.Notification,
+payloadSizeExceeded: boolean,
+encryptedPayloadHash?: string,
@@ -141,17 +141,17 @@
}>,
> {
const notificationPromises = devices.map(
- async ({ cookieID, deviceToken, blobHolder }) => {
+ async ({ cryptoID, deliveryID, blobHolder }) => {
const notif = await encryptAPNsNotification(
encryptedNotifUtilsAPI,
- cookieID,
+ cryptoID,
senderDeviceID,
notification,
codeVersion,
notificationSizeValidator,
blobHolder,
);
- return { cookieID, deviceToken, ...notif };
+ return { cryptoID, deliveryID, ...notif };
},
);
return Promise.all(notificationPromises);
@@ -165,23 +165,21 @@
codeVersion?: ?number,
): Promise<
$ReadOnlyArray<{
- +cookieID: string,
- +deviceToken: string,
+ +cryptoID: string,
+ +deliveryID: string,
+notification: apn.Notification,
}>,
> {
- const notificationPromises = devices.map(
- async ({ deviceToken, cookieID }) => {
- const { notification: notif } = await encryptAPNsNotification(
- encryptedNotifUtilsAPI,
- cookieID,
- senderDeviceID,
- notification,
- codeVersion,
- );
- return { deviceToken, cookieID, notification: notif };
- },
- );
+ const notificationPromises = devices.map(async ({ deliveryID, cryptoID }) => {
+ const { notification: notif } = await encryptAPNsNotification(
+ encryptedNotifUtilsAPI,
+ cryptoID,
+ senderDeviceID,
+ notification,
+ codeVersion,
+ );
+ return { cryptoID, deliveryID, notification: notif };
+ });
return Promise.all(notificationPromises);
}
diff --git a/keyserver/src/push/rescind.js b/keyserver/src/push/rescind.js
--- a/keyserver/src/push/rescind.js
+++ b/keyserver/src/push/rescind.js
@@ -152,8 +152,8 @@
if (delivery.platform === 'ios') {
const devices = delivery.deviceTokens.map(deviceToken => ({
- deviceToken,
- cookieID: deviceTokenToCookieID[deviceToken],
+ deliveryID: deviceToken,
+ cryptoID: deviceTokenToCookieID[deviceToken],
}));
const deliveryPromise = (async () => {
const targetedNotifications = await prepareIOSNotification(
@@ -175,8 +175,8 @@
deliveryPromises[id] = deliveryPromise;
} else if (delivery.platform === 'android') {
const devices = delivery.deviceTokens.map(deviceToken => ({
- deviceToken,
- cookieID: deviceTokenToCookieID[deviceToken],
+ deliveryID: deviceToken,
+ cryptoID: deviceTokenToCookieID[deviceToken],
}));
const deliveryPromise = (async () => {
const targetedNotifications = await prepareAndroidNotification(
@@ -289,17 +289,17 @@
) => Promise<
$ReadOnlyArray<{
+notification: T,
- +cookieID: string,
- +deviceToken: string,
+ +cryptoID: string,
+ +deliveryID: string,
+encryptionOrder?: number,
}>,
>,
-): Promise<$ReadOnlyArray<{ +deviceToken: string, +notification: T }>> {
+): Promise<$ReadOnlyArray<{ +deliveryID: string, +notification: T }>> {
const shouldBeEncrypted = codeVersion && codeVersion >= 233;
if (!shouldBeEncrypted) {
- return devices.map(({ deviceToken }) => ({
+ return devices.map(({ deliveryID }) => ({
notification,
- deviceToken,
+ deliveryID,
}));
}
const notifications = await encryptCallback(
@@ -309,8 +309,8 @@
notification,
codeVersion,
);
- return notifications.map(({ deviceToken, notification: notif }) => ({
- deviceToken,
+ return notifications.map(({ deliveryID, notification: notif }) => ({
+ deliveryID,
notification: notif,
}));
}
diff --git a/keyserver/src/push/send.js b/keyserver/src/push/send.js
--- a/keyserver/src/push/send.js
+++ b/keyserver/src/push/send.js
@@ -896,8 +896,8 @@
const innerMostArray = innerMostArrayTmp;
innerMostArray.push({
- cookieID: device.cookieID,
- deviceToken: device.deviceToken,
+ cryptoID: device.cookieID,
+ deliveryID: device.deviceToken,
});
}
return byPlatform;
@@ -1032,9 +1032,9 @@
)
? copyWithMessageInfos
: notification;
- return devices.map(({ deviceToken }) => ({
+ return devices.map(({ deliveryID }) => ({
notification: notificationToSend,
- deviceToken,
+ deliveryID,
}));
}
@@ -1050,9 +1050,9 @@
platformDetails.codeVersion,
);
return macOSNotifsWithoutMessageInfos.map(
- ({ notification: notif, deviceToken }) => ({
+ ({ notification: notif, deliveryID }) => ({
notification: notif,
- deviceToken,
+ deliveryID,
}),
);
}
@@ -1068,21 +1068,21 @@
const devicesWithExcessiveSizeNoHolders = notifsWithMessageInfos
.filter(({ payloadSizeExceeded }) => payloadSizeExceeded)
- .map(({ deviceToken, cookieID }) => ({
- deviceToken,
- cookieID,
+ .map(({ cryptoID, deliveryID }) => ({
+ cryptoID,
+ deliveryID,
}));
if (devicesWithExcessiveSizeNoHolders.length === 0) {
return notifsWithMessageInfos.map(
({
notification: notif,
- deviceToken,
+ deliveryID,
encryptedPayloadHash,
encryptionOrder,
}) => ({
notification: notif,
- deviceToken,
+ deliveryID,
encryptedPayloadHash,
encryptionOrder,
}),
@@ -1141,12 +1141,12 @@
.map(
({
notification: notif,
- deviceToken,
+ deliveryID,
encryptedPayloadHash,
encryptionOrder,
}) => ({
notification: notif,
- deviceToken,
+ deliveryID,
encryptedPayloadHash,
encryptionOrder,
}),
@@ -1155,12 +1155,12 @@
const targetedNotifsWithoutMessageInfos = notifsWithoutMessageInfos.map(
({
notification: notif,
- deviceToken,
+ deliveryID,
encryptedPayloadHash,
encryptionOrder,
}) => ({
notification: notif,
- deviceToken,
+ deliveryID,
encryptedPayloadHash,
encryptionOrder,
}),
@@ -1269,7 +1269,7 @@
);
const iosID = targetedNotifications[0].notification.id;
const deviceTokens = targetedNotifications.map(
- ({ deviceToken }) => deviceToken,
+ ({ deliveryID }) => deliveryID,
);
let delivery: APNsDelivery = {
source,
@@ -1289,7 +1289,7 @@
const deviceTokensToPayloadHash: { [string]: string } = {};
for (const targetedNotification of targetedNotifications) {
if (targetedNotification.encryptedPayloadHash) {
- deviceTokensToPayloadHash[targetedNotification.deviceToken] =
+ deviceTokensToPayloadHash[targetedNotification.deliveryID] =
targetedNotification.encryptedPayloadHash;
}
}
@@ -1340,7 +1340,7 @@
codeVersion,
});
const deviceTokens = targetedNotifications.map(
- ({ deviceToken }) => deviceToken,
+ ({ deliveryID }) => deliveryID,
);
const androidIDs = response.fcmIDs ? response.fcmIDs : [];
const delivery: AndroidDelivery = {
@@ -1386,7 +1386,7 @@
const response = await webPush(targetedNotifications);
const deviceTokens = targetedNotifications.map(
- ({ deviceToken }) => deviceToken,
+ ({ deliveryID }) => deliveryID,
);
const delivery: WebDelivery = {
source,
@@ -1427,7 +1427,7 @@
const response = await wnsPush(targetedNotifications);
const deviceTokens = targetedNotifications.map(
- ({ deviceToken }) => deviceToken,
+ ({ deliveryID }) => deliveryID,
);
const wnsIDs = response.wnsIDs ?? [];
const delivery: WNSDelivery = {
@@ -1571,16 +1571,16 @@
codeVersion,
);
targetedNotifications = notificationsArray.map(
- ({ notification: notif, deviceToken, encryptionOrder }) => ({
+ ({ notification: notif, deliveryID, encryptionOrder }) => ({
notification: notif,
- deviceToken,
+ deliveryID,
encryptionOrder,
}),
);
} else {
- targetedNotifications = deviceInfos.map(({ deviceToken }) => ({
+ targetedNotifications = deviceInfos.map(({ deliveryID }) => ({
notification,
- deviceToken,
+ deliveryID,
}));
}
return targetedNotifications.map(targetedNotification => ({
@@ -1623,17 +1623,17 @@
notification,
);
targetedNotifications = notificationsArray.map(
- ({ notification: notif, deviceToken, encryptionOrder }) => ({
+ ({ notification: notif, deliveryID, encryptionOrder }) => ({
priority,
notification: notif,
- deviceToken,
+ deliveryID,
encryptionOrder,
}),
);
} else {
- targetedNotifications = deviceInfos.map(({ deviceToken }) => ({
+ targetedNotifications = deviceInfos.map(({ deliveryID }) => ({
priority,
- deviceToken,
+ deliveryID,
notification,
}));
}
@@ -1683,15 +1683,15 @@
codeVersion,
);
targetedNotifications = notificationsArray.map(
- ({ notification: notif, deviceToken, encryptionOrder }) => ({
+ ({ notification: notif, deliveryID, encryptionOrder }) => ({
notification: notif,
- deviceToken,
+ deliveryID,
encryptionOrder,
}),
);
} else {
- targetedNotifications = deviceInfos.map(({ deviceToken }) => ({
- deviceToken,
+ targetedNotifications = deviceInfos.map(({ deliveryID }) => ({
+ deliveryID,
notification,
}));
}
diff --git a/keyserver/src/push/types.js b/keyserver/src/push/types.js
--- a/keyserver/src/push/types.js
+++ b/keyserver/src/push/types.js
@@ -4,7 +4,7 @@
export type TargetedAPNsNotification = {
+notification: apn.Notification,
- +deviceToken: string,
+ +deliveryID: string,
+encryptedPayloadHash?: string,
+encryptionOrder?: number,
};
diff --git a/keyserver/src/push/utils.js b/keyserver/src/push/utils.js
--- a/keyserver/src/push/utils.js
+++ b/keyserver/src/push/utils.js
@@ -68,8 +68,8 @@
invariant(apnProvider, `keyserver/secrets/${pushProfile}.json should exist`);
const results = await Promise.all(
- targetedNotifications.map(({ notification, deviceToken }) => {
- return apnProvider.send(notification, deviceToken);
+ targetedNotifications.map(({ notification, deliveryID }) => {
+ return apnProvider.send(notification, deliveryID);
}),
);
@@ -133,8 +133,8 @@
// avoid the multicast functionality and call it once per deviceToken.
const results = await Promise.all(
- targetedNotifications.map(({ notification, deviceToken, priority }) => {
- return fcmSinglePush(fcmProvider, notification, deviceToken, {
+ targetedNotifications.map(({ notification, deliveryID, priority }) => {
+ return fcmSinglePush(fcmProvider, notification, deliveryID, {
...options,
priority,
});
@@ -153,7 +153,7 @@
? error.error.errorInfo.code
: undefined;
if (errorCode && fcmTokenInvalidationErrors.has(errorCode)) {
- invalidTokens.push(targetedNotifications[i].deviceToken);
+ invalidTokens.push(targetedNotifications[i].deliveryID);
}
}
for (const id of pushResult.fcmIDs) {
@@ -256,7 +256,7 @@
const pushResults: $ReadOnlyArray<WebPushAttempt> = await Promise.all(
targetedNotifications.map(
- async ({ notification, deviceToken: deviceTokenString }) => {
+ async ({ notification, deliveryID: deviceTokenString }) => {
const deviceToken: PushSubscriptionJSON = JSON.parse(deviceTokenString);
const notificationString = JSON.stringify(notification);
try {
@@ -272,7 +272,7 @@
const errors = [];
const invalidTokens = [];
const deviceTokens = targetedNotifications.map(
- ({ deviceToken }) => deviceToken,
+ ({ deliveryID }) => deliveryID,
);
for (let i = 0; i < pushResults.length; i++) {
const pushResult = pushResults[i];
@@ -324,7 +324,7 @@
return await wnsSinglePush(
token,
notificationString,
- targetedNotification.deviceToken,
+ targetedNotification.deliveryID,
);
} catch (error) {
return { error };
@@ -335,7 +335,7 @@
const notifIDs = [];
const invalidTokens = [];
const deviceTokens = targetedNotifications.map(
- ({ deviceToken }) => deviceToken,
+ ({ deliveryID }) => deliveryID,
);
for (let i = 0; i < pushResults.length; i++) {
const pushResult = await pushResults[i];
diff --git a/lib/push/crypto.js b/lib/push/crypto.js
--- a/lib/push/crypto.js
+++ b/lib/push/crypto.js
@@ -264,24 +264,24 @@
) => boolean,
): Promise<
$ReadOnlyArray<{
- +cookieID: string,
- +deviceToken: string,
+ +cryptoID: string,
+ +deliveryID: string,
+notification: AndroidVisualNotification,
+payloadSizeExceeded: boolean,
+encryptionOrder?: number,
}>,
> {
const notificationPromises = devices.map(
- async ({ deviceToken, cookieID, blobHolder }) => {
+ async ({ deliveryID, cryptoID, blobHolder }) => {
const notif = await encryptAndroidVisualNotification(
encryptedNotifUtilsAPI,
senderDeviceID,
- cookieID,
+ cryptoID,
notification,
notificationSizeValidator,
blobHolder,
);
- return { deviceToken, cookieID, ...notif };
+ return { deliveryID, cryptoID, ...notif };
},
);
return Promise.all(notificationPromises);
@@ -294,23 +294,21 @@
notification: AndroidNotificationRescind | AndroidBadgeOnlyNotification,
): Promise<
$ReadOnlyArray<{
- +cookieID: string,
- +deviceToken: string,
+ +cryptoID: string,
+ +deliveryID: string,
+notification: AndroidNotificationRescind | AndroidBadgeOnlyNotification,
+encryptionOrder?: number,
}>,
> {
- const notificationPromises = devices.map(
- async ({ deviceToken, cookieID }) => {
- const notif = await encryptAndroidSilentNotification(
- encryptedNotifUtilsAPI,
- cookieID,
- senderDeviceID,
- notification,
- );
- return { deviceToken, cookieID, notification: notif };
- },
- );
+ const notificationPromises = devices.map(async ({ deliveryID, cryptoID }) => {
+ const notif = await encryptAndroidSilentNotification(
+ encryptedNotifUtilsAPI,
+ cryptoID,
+ senderDeviceID,
+ notification,
+ );
+ return { deliveryID, cryptoID, notification: notif };
+ });
return Promise.all(notificationPromises);
}
@@ -321,22 +319,20 @@
notification: PlainTextWebNotification,
): Promise<
$ReadOnlyArray<{
- +deviceToken: string,
+ +deliveryID: string,
+notification: WebNotification,
+encryptionOrder?: number,
}>,
> {
- const notificationPromises = devices.map(
- async ({ deviceToken, cookieID }) => {
- const notif = await encryptWebNotification(
- encryptedNotifUtilsAPI,
- cookieID,
- senderDeviceID,
- notification,
- );
- return { ...notif, deviceToken };
- },
- );
+ const notificationPromises = devices.map(async ({ deliveryID, cryptoID }) => {
+ const notif = await encryptWebNotification(
+ encryptedNotifUtilsAPI,
+ cryptoID,
+ senderDeviceID,
+ notification,
+ );
+ return { ...notif, deliveryID };
+ });
return Promise.all(notificationPromises);
}
@@ -347,22 +343,20 @@
notification: PlainTextWNSNotification,
): Promise<
$ReadOnlyArray<{
- +deviceToken: string,
+ +deliveryID: string,
+notification: WNSNotification,
+encryptionOrder?: number,
}>,
> {
- const notificationPromises = devices.map(
- async ({ deviceToken, cookieID }) => {
- const notif = await encryptWNSNotification(
- encryptedNotifUtilsAPI,
- cookieID,
- senderDeviceID,
- notification,
- );
- return { ...notif, deviceToken };
- },
- );
+ const notificationPromises = devices.map(async ({ deliveryID, cryptoID }) => {
+ const notif = await encryptWNSNotification(
+ encryptedNotifUtilsAPI,
+ cryptoID,
+ senderDeviceID,
+ notification,
+ );
+ return { ...notif, deliveryID };
+ });
return Promise.all(notificationPromises);
}
diff --git a/lib/push/notif-creators.js b/lib/push/notif-creators.js
--- a/lib/push/notif-creators.js
+++ b/lib/push/notif-creators.js
@@ -137,10 +137,10 @@
? copyWithMessageInfos
: notification;
- return devices.map(({ deviceToken }) => ({
+ return devices.map(({ deliveryID }) => ({
priority,
notification: notificationToSend,
- deviceToken,
+ deliveryID,
}));
}
@@ -164,14 +164,14 @@
const devicesWithExcessiveSizeNoHolders = notifsWithMessageInfos
.filter(({ payloadSizeExceeded }) => payloadSizeExceeded)
- .map(({ cookieID, deviceToken }) => ({ cookieID, deviceToken }));
+ .map(({ cryptoID, deliveryID }) => ({ cryptoID, deliveryID }));
if (devicesWithExcessiveSizeNoHolders.length === 0) {
return notifsWithMessageInfos.map(
- ({ notification: notif, deviceToken, encryptionOrder }) => ({
+ ({ notification: notif, deliveryID, encryptionOrder }) => ({
priority,
notification: notif,
- deviceToken,
+ deliveryID,
encryptionOrder,
}),
);
@@ -226,18 +226,18 @@
const targetedNotifsWithMessageInfos = notifsWithMessageInfos
.filter(({ payloadSizeExceeded }) => !payloadSizeExceeded)
- .map(({ notification: notif, deviceToken, encryptionOrder }) => ({
+ .map(({ notification: notif, deliveryID, encryptionOrder }) => ({
priority,
notification: notif,
- deviceToken,
+ deliveryID,
encryptionOrder,
}));
const targetedNotifsWithoutMessageInfos = notifsWithoutMessageInfos.map(
- ({ notification: notif, deviceToken, encryptionOrder }) => ({
+ ({ notification: notif, deliveryID, encryptionOrder }) => ({
priority,
notification: notif,
- deviceToken,
+ deliveryID,
encryptionOrder,
}),
);
@@ -287,7 +287,7 @@
});
if (!shouldBeEncrypted) {
- return devices.map(({ deviceToken }) => ({ deviceToken, notification }));
+ return devices.map(({ deliveryID }) => ({ deliveryID, notification }));
}
return prepareEncryptedWebNotifications(
@@ -340,8 +340,8 @@
});
if (!shouldBeEncrypted) {
- return devices.map(({ deviceToken }) => ({
- deviceToken,
+ return devices.map(({ deliveryID }) => ({
+ deliveryID,
notification,
}));
}
diff --git a/lib/types/notif-types.js b/lib/types/notif-types.js
--- a/lib/types/notif-types.js
+++ b/lib/types/notif-types.js
@@ -182,25 +182,25 @@
export type TargetedAndroidNotification = $ReadOnly<{
...AndroidNotificationWithPriority,
- +deviceToken: string,
+ +deliveryID: string,
+encryptionOrder?: number,
}>;
export type TargetedWebNotification = {
+notification: WebNotification,
- +deviceToken: string,
+ +deliveryID: string,
+encryptionOrder?: number,
};
export type TargetedWNSNotification = {
+notification: WNSNotification,
- +deviceToken: string,
+ +deliveryID: string,
+encryptionOrder?: number,
};
export type NotificationTargetDevice = {
- +cookieID: string,
- +deviceToken: string,
+ +cryptoID: string,
+ +deliveryID: string,
+blobHolder?: string,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Sep 29, 5:35 PM (20 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2201898
Default Alt Text
D12398.id41215.diff (19 KB)
Attached To
Mode
D12398: Rename cookieID -> cryptoID and deviceToken -> deliveryID
Attached
Detach File
Event Timeline
Log In to Comment