Page MenuHomePhabricator

D11302.id38225.diff
No OneTemporary

D11302.id38225.diff

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
@@ -11,6 +11,7 @@
PlainTextWebNotificationPayload,
WebNotification,
PlainTextWNSNotification,
+ PlainTextWNSNotificationPayload,
WNSNotification,
} from 'lib/types/notif-types.js';
import { toBase64URL } from 'lib/utils/base64.js';
@@ -289,22 +290,32 @@
cookieID: string,
notification: PlainTextWebNotification,
): Promise<{ +notification: WebNotification, +encryptionOrder?: number }> {
- const { id, ...payloadSansId } = notification;
+ const { id, keyserverID, ...payloadSansId } = notification;
const { encryptionOrder, ...encryptionResult } =
await encryptBasicPayload<PlainTextWebNotificationPayload>(
cookieID,
payloadSansId,
);
- return { notification: { id, ...encryptionResult }, encryptionOrder };
+ return {
+ notification: { id, keyserverID, ...encryptionResult },
+ encryptionOrder,
+ };
}
async function encryptWNSNotification(
cookieID: string,
notification: PlainTextWNSNotification,
): Promise<{ +notification: WNSNotification, +encryptionOrder?: number }> {
+ const { keyserverID, ...payloadSansKeyserverID } = notification;
const { encryptionOrder, ...encryptionResult } =
- await encryptBasicPayload<PlainTextWNSNotification>(cookieID, notification);
- return { notification: encryptionResult, encryptionOrder };
+ await encryptBasicPayload<PlainTextWNSNotificationPayload>(
+ cookieID,
+ payloadSansKeyserverID,
+ );
+ return {
+ notification: { keyserverID, ...encryptionResult },
+ encryptionOrder,
+ };
}
function prepareEncryptedAPNsNotifications(
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
@@ -407,6 +407,7 @@
{
notifTexts,
threadID: threadInfo.id,
+ keyserverID,
unreadCount,
platformDetails,
},
@@ -486,6 +487,7 @@
const targetedNotifications = await prepareWNSNotification(devices, {
notifTexts,
threadID: threadInfo.id,
+ keyserverID,
unreadCount,
platformDetails,
});
@@ -977,9 +979,6 @@
...notification.payload,
...rest,
};
- if (platformDetails.platform !== 'macos') {
- notification.payload.keyserverID = keyserverID;
- }
notification.badge = unreadCount;
notification.threadId = threadID;
@@ -987,6 +986,7 @@
notification.pushType = 'alert';
notification.payload.id = uniqueID;
notification.payload.threadID = threadID;
+ notification.payload.keyserverID = keyserverID;
if (platformDetails.codeVersion && platformDetails.codeVersion > 198) {
notification.mutableContent = true;
@@ -1246,12 +1246,14 @@
type WebNotifInputData = {
+notifTexts: ResolvedNotifTexts,
+threadID: string,
+ +keyserverID: string,
+unreadCount: number,
+platformDetails: PlatformDetails,
};
const webNotifInputDataValidator = tShape<WebNotifInputData>({
notifTexts: resolvedNotifTextsValidator,
threadID: tID,
+ keyserverID: t.String,
unreadCount: t.Number,
platformDetails: tPlatformDetails,
});
@@ -1264,7 +1266,7 @@
webNotifInputDataValidator,
inputData,
);
- const { notifTexts, threadID, unreadCount } = convertedData;
+ const { notifTexts, threadID, unreadCount, keyserverID } = convertedData;
const id = uuidv4();
const { merged, ...rest } = notifTexts;
const notification = {
@@ -1272,6 +1274,7 @@
unreadCount,
id,
threadID,
+ keyserverID,
};
const shouldBeEncrypted = hasMinCodeVersion(convertedData.platformDetails, {
@@ -1288,12 +1291,14 @@
type WNSNotifInputData = {
+notifTexts: ResolvedNotifTexts,
+threadID: string,
+ +keyserverID: string,
+unreadCount: number,
+platformDetails: PlatformDetails,
};
const wnsNotifInputDataValidator = tShape<WNSNotifInputData>({
notifTexts: resolvedNotifTextsValidator,
threadID: tID,
+ keyserverID: t.String,
unreadCount: t.Number,
platformDetails: tPlatformDetails,
});
@@ -1306,12 +1311,13 @@
wnsNotifInputDataValidator,
inputData,
);
- const { notifTexts, threadID, unreadCount } = convertedData;
+ const { notifTexts, threadID, unreadCount, keyserverID } = convertedData;
const { merged, ...rest } = notifTexts;
const notification = {
...rest,
unreadCount,
threadID,
+ keyserverID,
};
if (
@@ -1780,6 +1786,7 @@
});
notification.badge = unreadCount;
notification.pushType = 'alert';
+ notification.payload.keyserverID = keyserverID;
const preparePromise: Promise<PreparePushResult[]> = (async () => {
const shouldBeEncrypted = hasMinCodeVersion(viewer.platformDetails, {
web: 47,
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
@@ -37,11 +37,13 @@
export type PlainTextWebNotification = {
+id: string,
+ +keyserverID: string,
...PlainTextWebNotificationPayload,
};
export type EncryptedWebNotification = {
+id: string,
+ +keyserverID: string,
+encryptedPayload: string,
};
@@ -49,7 +51,7 @@
| PlainTextWebNotification
| EncryptedWebNotification;
-export type PlainTextWNSNotification = {
+export type PlainTextWNSNotificationPayload = {
+body: string,
+prefix?: string,
+title: string,
@@ -58,7 +60,13 @@
+encryptionFailed?: '1',
};
+export type PlainTextWNSNotification = {
+ +keyserverID: string,
+ ...PlainTextWNSNotificationPayload,
+};
+
export type EncryptedWNSNotification = {
+ +keyserverID: string,
+encryptedPayload: string,
};

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 3:42 AM (21 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2510482
Default Alt Text
D11302.id38225.diff (5 KB)

Event Timeline