Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3267635
D11303.id38222.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D11303.id38222.diff
View Options
diff --git a/desktop/flow-typed/npm/electron_v22.0.0.js b/desktop/flow-typed/npm/electron_v22.0.0.js
--- a/desktop/flow-typed/npm/electron_v22.0.0.js
+++ b/desktop/flow-typed/npm/electron_v22.0.0.js
@@ -336,7 +336,7 @@
declare type PushNotificationsEvents = {
'received-apns-notification': (
event: Event,
- userInfo: { +[string]: mixed, +encryptedPayload?: string },
+ userInfo: {+[string]: mixed},
) => void,
};
diff --git a/desktop/src/main.js b/desktop/src/main.js
--- a/desktop/src/main.js
+++ b/desktop/src/main.js
@@ -304,10 +304,14 @@
}
};
- const handleEncryptedNotification = (encryptedPayload: string) => {
+ const handleEncryptedNotification = (
+ encryptedPayload: string,
+ keyserverID: string,
+ ) => {
if (mainWindow) {
mainWindow.webContents.send('on-encrypted-notification', {
encryptedPayload,
+ keyserverID,
});
}
};
diff --git a/desktop/src/push-notifications.js b/desktop/src/push-notifications.js
--- a/desktop/src/push-notifications.js
+++ b/desktop/src/push-notifications.js
@@ -129,23 +129,34 @@
function listenForNotifications(
handleClick: (threadID?: string) => void,
- handleEncryptedNotification: (encryptedPayload: string) => void,
+ handleEncryptedNotification: (
+ encryptedPayload: string,
+ keyserverID: string,
+ ) => void,
) {
if (process.platform === 'darwin') {
pushNotifications.on('received-apns-notification', (event, userInfo) => {
- if (userInfo.encryptedPayload) {
- handleEncryptedNotification(userInfo.encryptedPayload);
- } else {
- showNewNotification(userInfo, handleClick);
+ const { keyserverID, encryptedPayload } = userInfo;
+ if (
+ typeof keyserverID === 'string' &&
+ typeof encryptedPayload === 'string'
+ ) {
+ handleEncryptedNotification(encryptedPayload, keyserverID);
+ return;
}
+ showNewNotification(userInfo, handleClick);
});
} else if (process.platform === 'win32') {
windowsPushNotifEventEmitter.on('received-wns-notification', payload => {
- if (payload.encryptedPayload) {
- handleEncryptedNotification(payload.encryptedPayload);
- } else {
- showNewNotification(payload, handleClick);
+ const { keyserverID, encryptedPayload } = payload;
+ if (
+ typeof keyserverID === 'string' &&
+ typeof encryptedPayload === 'string'
+ ) {
+ handleEncryptedNotification(encryptedPayload, keyserverID);
+ return;
}
+ showNewNotification(payload, handleClick);
});
}
}
diff --git a/lib/types/electron-types.js b/lib/types/electron-types.js
--- a/lib/types/electron-types.js
+++ b/lib/types/electron-types.js
@@ -13,6 +13,7 @@
type OnEncryptedNotificationListener = (data: {
encryptedPayload: string,
+ keyserverID?: string,
}) => mixed;
export type ElectronBridge = {
diff --git a/web/account/account-hooks.js b/web/account/account-hooks.js
--- a/web/account/account-hooks.js
+++ b/web/account/account-hooks.js
@@ -283,7 +283,7 @@
);
const notifsOlmDataEncryptionKeyDBLabel =
- getOlmEncryptionKeyDBLabelForCookie(cookie);
+ getOlmEncryptionKeyDBLabelForCookie(cookie, keyserverID);
const notifsOlmDataContentKey = getOlmDataContentKeyForCookie(
cookie,
keyserverID,
diff --git a/web/push-notif/notif-crypto-utils.js b/web/push-notif/notif-crypto-utils.js
--- a/web/push-notif/notif-crypto-utils.js
+++ b/web/push-notif/notif-crypto-utils.js
@@ -107,6 +107,8 @@
async function decryptDesktopNotification(
encryptedPayload: string,
staffCanSee: boolean,
+ // eslint-disable-next-line no-unused-vars
+ keyserverID?: string,
): Promise<{ +[string]: mixed }> {
let encryptedOlmData, encryptionKey, olmDataContentKey;
try {
@@ -342,7 +344,11 @@
return `${NOTIFICATIONS_OLM_DATA_CONTENT}:${cookieID}`;
}
-function getOlmEncryptionKeyDBLabelForCookie(cookie: ?string): string {
+function getOlmEncryptionKeyDBLabelForCookie(
+ cookie: ?string,
+ // eslint-disable-next-line no-unused-vars
+ keyserverID: string,
+): string {
if (!cookie) {
return NOTIFICATIONS_OLM_DATA_ENCRYPTION_KEY;
}
diff --git a/web/push-notif/push-notifs-handler.js b/web/push-notif/push-notifs-handler.js
--- a/web/push-notif/push-notifs-handler.js
+++ b/web/push-notif/push-notifs-handler.js
@@ -48,10 +48,17 @@
React.useEffect(
() =>
electron?.onEncryptedNotification?.(
- async ({ encryptedPayload }: { encryptedPayload: string }) => {
+ async ({
+ encryptedPayload,
+ keyserverID,
+ }: {
+ encryptedPayload: string,
+ keyserverID?: string,
+ }) => {
const decryptedPayload = await decryptDesktopNotification(
encryptedPayload,
staffCanSee,
+ keyserverID,
);
electron?.showDecryptedNotification(decryptedPayload);
},
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 2:59 AM (21 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2511367
Default Alt Text
D11303.id38222.diff (4 KB)
Attached To
Mode
D11303: Boilerplate for web and desktop to look for keyserverID during notifications session creation and notification decryption
Attached
Detach File
Event Timeline
Log In to Comment