Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3490659
D11303.id37999.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.id37999.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,11 @@
declare type PushNotificationsEvents = {
'received-apns-notification': (
event: Event,
- userInfo: { +[string]: mixed, +encryptedPayload?: string },
+ userInfo: {
+ +[string]: mixed,
+ +keyserverID: string,
+ +encryptedPayload?: string
+ },
) => void,
};
diff --git a/desktop/src/main.js b/desktop/src/main.js
--- a/desktop/src/main.js
+++ b/desktop/src/main.js
@@ -304,9 +304,13 @@
}
};
- const handleEncryptedNotification = (encryptedPayload: string) => {
+ const handleEncryptedNotification = (
+ keyserverID: string,
+ encryptedPayload: string,
+ ) => {
if (mainWindow) {
mainWindow.webContents.send('on-encrypted-notification', {
+ keyserverID,
encryptedPayload,
});
}
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,12 +129,18 @@
function listenForNotifications(
handleClick: (threadID?: string) => void,
- handleEncryptedNotification: (encryptedPayload: string) => void,
+ handleEncryptedNotification: (
+ keyserverID: string,
+ encryptedPayload: string,
+ ) => void,
) {
if (process.platform === 'darwin') {
pushNotifications.on('received-apns-notification', (event, userInfo) => {
if (userInfo.encryptedPayload) {
- handleEncryptedNotification(userInfo.encryptedPayload);
+ handleEncryptedNotification(
+ userInfo.keyserverID,
+ userInfo.encryptedPayload,
+ );
} else {
showNewNotification(userInfo, handleClick);
}
@@ -142,7 +148,10 @@
} else if (process.platform === 'win32') {
windowsPushNotifEventEmitter.on('received-wns-notification', payload => {
if (payload.encryptedPayload) {
- handleEncryptedNotification(payload.encryptedPayload);
+ handleEncryptedNotification(
+ payload.keyserverID,
+ payload.encryptedPayload,
+ );
} else {
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
@@ -12,6 +12,7 @@
type OnNotificationClickedListener = (data: { threadID: string }) => void;
type OnEncryptedNotificationListener = (data: {
+ keyserverID: string,
encryptedPayload: string,
}) => mixed;
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
@@ -288,7 +288,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
@@ -105,6 +105,7 @@
}
async function decryptDesktopNotification(
+ keyserverID: string,
encryptedPayload: string,
staffCanSee: boolean,
): Promise<{ +[string]: mixed }> {
@@ -342,7 +343,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
@@ -54,8 +54,15 @@
React.useEffect(
() =>
electron?.onEncryptedNotification?.(
- async ({ encryptedPayload }: { encryptedPayload: string }) => {
+ async ({
+ keyserverID,
+ encryptedPayload,
+ }: {
+ keyserverID: string,
+ encryptedPayload: string,
+ }) => {
const decryptedPayload = await decryptDesktopNotification(
+ keyserverID,
encryptedPayload,
staffCanSee,
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 5:03 PM (20 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678081
Default Alt Text
D11303.id37999.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