Page MenuHomePhabricator

D9147.id30965.diff
No OneTemporary

D9147.id30965.diff

diff --git a/lib/utils/migration-utils.js b/lib/utils/migration-utils.js
--- a/lib/utils/migration-utils.js
+++ b/lib/utils/migration-utils.js
@@ -22,25 +22,7 @@
function convertDraftKeyToNewIDSchema(key: string): string {
const threadID = key.slice(0, -draftKeySuffix.length);
-
- const pendingIDContents = parsePendingThreadID(threadID);
-
- if (!pendingIDContents) {
- return `${ashoatKeyserverID}|${key}`;
- }
-
- const { threadType, sourceMessageID, memberIDs } = pendingIDContents;
-
- if (!sourceMessageID) {
- return key;
- }
-
- const convertedThreadID = getPendingThreadID(
- threadType,
- memberIDs,
- `${ashoatKeyserverID}|${sourceMessageID}`,
- );
-
+ const convertedThreadID = convertIDToNewSchema(threadID, ashoatKeyserverID);
return `${convertedThreadID}${draftKeySuffix}`;
}
@@ -90,9 +72,32 @@
);
}
-function convertNotificationThreadIDToNewIDSchema(threadID: string): string {
+function convertIDToNewSchema(threadID: string, idPrefix: string): string {
+ const pendingIDContents = parsePendingThreadID(threadID);
+
+ if (!pendingIDContents) {
+ return convertNonPendingIDToNewSchema(threadID, idPrefix);
+ }
+
+ const { threadType, sourceMessageID, memberIDs } = pendingIDContents;
+
+ if (!sourceMessageID) {
+ return threadID;
+ }
+
+ return getPendingThreadID(
+ threadType,
+ memberIDs,
+ convertNonPendingIDToNewSchema(sourceMessageID, idPrefix),
+ );
+}
+
+function convertNonPendingIDToNewSchema(
+ threadID: string,
+ idPrefix: string,
+): string {
if (threadID.indexOf('|') === -1) {
- return `${ashoatKeyserverID}|${threadID}`;
+ return `${idPrefix}|${threadID}`;
}
return threadID;
}
@@ -117,6 +122,7 @@
generateIDSchemaMigrationOpsForDrafts,
convertMessageStoreThreadsToNewIDSchema,
convertThreadStoreThreadInfosToNewIDSchema,
- convertNotificationThreadIDToNewIDSchema,
+ convertNonPendingIDToNewSchema,
+ convertIDToNewSchema,
convertNotificationMessageInfoToNewIDSchema,
};
diff --git a/native/push/android.js b/native/push/android.js
--- a/native/push/android.js
+++ b/native/push/android.js
@@ -5,9 +5,10 @@
import { mergePrefixIntoBody } from 'lib/shared/notif-utils.js';
import type { RawMessageInfo } from 'lib/types/message-types.js';
import {
- convertNotificationThreadIDToNewIDSchema,
+ convertNonPendingIDToNewSchema,
convertNotificationMessageInfoToNewIDSchema,
} from 'lib/utils/migration-utils.js';
+import { ashoatKeyserverID } from 'lib/utils/validation-utils.js';
type CommAndroidNotificationsConstants = {
+NOTIFICATIONS_IMPORTANCE_HIGH: number,
@@ -50,7 +51,10 @@
function parseAndroidMessage(message: AndroidMessage): ParsedAndroidMessage {
return {
...message,
- threadID: convertNotificationThreadIDToNewIDSchema(message.threadID),
+ threadID: convertNonPendingIDToNewSchema(
+ message.threadID,
+ ashoatKeyserverID,
+ ),
messageInfos: convertNotificationMessageInfoToNewIDSchema(
message.messageInfos,
),
diff --git a/native/push/comm-ios-notification.js b/native/push/comm-ios-notification.js
--- a/native/push/comm-ios-notification.js
+++ b/native/push/comm-ios-notification.js
@@ -4,9 +4,10 @@
import type { RawMessageInfo } from 'lib/types/message-types.js';
import {
- convertNotificationThreadIDToNewIDSchema,
+ convertNonPendingIDToNewSchema,
convertNotificationMessageInfoToNewIDSchema,
} from 'lib/utils/migration-utils.js';
+import { ashoatKeyserverID } from 'lib/utils/validation-utils.js';
const { CommIOSNotifications } = NativeModules;
@@ -50,7 +51,10 @@
this.data = {
...notification,
- threadID: convertNotificationThreadIDToNewIDSchema(notification.threadID),
+ threadID: convertNonPendingIDToNewSchema(
+ notification.threadID,
+ ashoatKeyserverID,
+ ),
messageInfos: convertNotificationMessageInfoToNewIDSchema(
notification.messageInfos,
),
diff --git a/native/push/push-handler.react.js b/native/push/push-handler.react.js
--- a/native/push/push-handler.react.js
+++ b/native/push/push-handler.react.js
@@ -33,7 +33,7 @@
} from 'lib/utils/action-utils.js';
import {
convertNotificationMessageInfoToNewIDSchema,
- convertNotificationThreadIDToNewIDSchema,
+ convertNonPendingIDToNewSchema,
} from 'lib/utils/migration-utils.js';
import {
type NotifPermissionAlertInfo,
@@ -41,6 +41,7 @@
shouldSkipPushPermissionAlert,
} from 'lib/utils/push-alerts.js';
import sleep from 'lib/utils/sleep.js';
+import { ashoatKeyserverID } from 'lib/utils/validation-utils.js';
import {
parseAndroidMessage,
@@ -594,8 +595,10 @@
}
androidNotificationOpened = async (threadID: string) => {
- const convertedThreadID =
- convertNotificationThreadIDToNewIDSchema(threadID);
+ const convertedThreadID = convertNonPendingIDToNewSchema(
+ threadID,
+ ashoatKeyserverID,
+ );
this.onPushNotifBootsApp();
this.onPressNotificationForThread(convertedThreadID, true);
};
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
@@ -13,11 +13,12 @@
useDispatchActionPromise,
useServerCall,
} from 'lib/utils/action-utils.js';
-import { convertNotificationThreadIDToNewIDSchema } from 'lib/utils/migration-utils.js';
+import { convertNonPendingIDToNewSchema } from 'lib/utils/migration-utils.js';
import {
shouldSkipPushPermissionAlert,
recordNotifPermissionAlertActionType,
} from 'lib/utils/push-alerts.js';
+import { ashoatKeyserverID } from 'lib/utils/validation-utils.js';
import electron from '../electron.js';
import PushNotifModal from '../modals/push-notif-modal.react.js';
@@ -44,8 +45,10 @@
React.useEffect(
() =>
electron?.onNotificationClicked?.(({ threadID }) => {
- const convertedThreadID =
- convertNotificationThreadIDToNewIDSchema(threadID);
+ const convertedThreadID = convertNonPendingIDToNewSchema(
+ threadID,
+ ashoatKeyserverID,
+ );
const payload = {
chatMode: 'view',
diff --git a/web/push-notif/service-worker.js b/web/push-notif/service-worker.js
--- a/web/push-notif/service-worker.js
+++ b/web/push-notif/service-worker.js
@@ -1,7 +1,8 @@
// @flow
import type { WebNotification } from 'lib/types/notif-types.js';
-import { convertNotificationThreadIDToNewIDSchema } from 'lib/utils/migration-utils.js';
+import { convertNonPendingIDToNewSchema } from 'lib/utils/migration-utils.js';
+import { ashoatKeyserverID } from 'lib/utils/validation-utils.js';
declare class PushMessageData {
json(): Object;
@@ -55,8 +56,9 @@
const selectedClient =
clientList.find(client => client.focused) ?? clientList[0];
- const threadID = convertNotificationThreadIDToNewIDSchema(
+ const threadID = convertNonPendingIDToNewSchema(
event.notification.data.threadID,
+ ashoatKeyserverID,
);
if (selectedClient) {

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 2:50 AM (18 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587436
Default Alt Text
D9147.id30965.diff (6 KB)

Event Timeline