Page MenuHomePhabricator

D12394.diff
No OneTemporary

D12394.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
@@ -13,16 +13,14 @@
PlainTextWNSNotification,
PlainTextWNSNotificationPayload,
WNSNotification,
-} from 'lib/types/notif-types.js';
-import { toBase64URL } from 'lib/utils/base64.js';
-
-import type {
AndroidVisualNotification,
AndroidVisualNotificationPayload,
AndroidBadgeOnlyNotification,
AndroidNotificationRescind,
NotificationTargetDevice,
-} from './types.js';
+} from 'lib/types/notif-types.js';
+import { toBase64URL } from 'lib/utils/base64.js';
+
import { encryptAndUpdateOlmSession } from '../updaters/olm-session-updater.js';
import { encrypt, generateKey } from '../utils/aes-crypto-utils.js';
import { getOlmUtility } from '../utils/olm-utils.js';
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
@@ -6,6 +6,10 @@
import invariant from 'invariant';
import type { PlatformDetails } from 'lib/types/device-types.js';
+import type {
+ NotificationTargetDevice,
+ TargetedAndroidNotification,
+} from 'lib/types/notif-types.js';
import { threadSubscriptions } from 'lib/types/subscription-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
import { promiseAll } from 'lib/utils/promises.js';
@@ -16,11 +20,7 @@
prepareEncryptedIOSNotificationRescind,
} from './crypto.js';
import { getAPNsNotificationTopic } from './providers.js';
-import type {
- NotificationTargetDevice,
- TargetedAndroidNotification,
- TargetedAPNsNotification,
-} from './types.js';
+import type { TargetedAPNsNotification } from './types.js';
import {
apnPush,
fcmPush,
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
@@ -34,7 +34,14 @@
rawMessageInfoValidator,
} from 'lib/types/message-types.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
-import type { ResolvedNotifTexts } from 'lib/types/notif-types.js';
+import type {
+ AndroidVisualNotification,
+ NotificationTargetDevice,
+ TargetedAndroidNotification,
+ TargetedWebNotification,
+ TargetedWNSNotification,
+ ResolvedNotifTexts,
+} from 'lib/types/notif-types.js';
import { resolvedNotifTextsValidator } from 'lib/types/notif-types.js';
import type { ServerThreadInfo } from 'lib/types/thread-types.js';
import { updateTypes } from 'lib/types/update-types-enum.js';
@@ -51,14 +58,7 @@
} from './crypto.js';
import { getAPNsNotificationTopic } from './providers.js';
import { rescindPushNotifs } from './rescind.js';
-import type {
- AndroidVisualNotification,
- NotificationTargetDevice,
- TargetedAndroidNotification,
- TargetedAPNsNotification,
- TargetedWebNotification,
- TargetedWNSNotification,
-} from './types.js';
+import type { TargetedAPNsNotification } from './types.js';
import {
apnMaxNotificationPayloadByteSize,
apnPush,
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
@@ -2,118 +2,9 @@
import apn from '@parse/node-apn';
-import type {
- WebNotification,
- WNSNotification,
-} from 'lib/types/notif-types.js';
-
export type TargetedAPNsNotification = {
+notification: apn.Notification,
+deviceToken: string,
+encryptedPayloadHash?: string,
+encryptionOrder?: number,
};
-
-export type AndroidVisualNotificationPayloadBase = $ReadOnly<{
- +badge: string,
- +body: string,
- +title: string,
- +prefix?: string,
- +threadID: string,
- +collapseKey?: string,
- +badgeOnly?: '0',
- +encryptionFailed?: '1',
-}>;
-
-export type AndroidVisualNotificationPayload = $ReadOnly<
- | {
- ...AndroidVisualNotificationPayloadBase,
- +messageInfos?: string,
- }
- | {
- ...AndroidVisualNotificationPayloadBase,
- +blobHash: string,
- +encryptionKey: string,
- },
->;
-
-export type AndroidVisualNotification = {
- +data: $ReadOnly<{
- +id?: string,
- +keyserverID: string,
- ...
- | {
- ...AndroidVisualNotificationPayloadBase,
- +messageInfos?: string,
- }
- | {
- ...AndroidVisualNotificationPayloadBase,
- +blobHash: string,
- +encryptionKey: string,
- }
- | { +encryptedPayload: string },
- }>,
-};
-
-export type AndroidNotificationRescind = {
- +data: $ReadOnly<{
- +keyserverID: string,
- ...
- | {
- +badge: string,
- +rescind: 'true',
- +rescindID: string,
- +setUnreadStatus: 'true',
- +threadID: string,
- +encryptionFailed?: string,
- }
- | { +encryptedPayload: string },
- }>,
-};
-
-export type AndroidBadgeOnlyNotification = {
- +data: $ReadOnly<{
- +keyserverID: string,
- ...
- | {
- +badge: string,
- +badgeOnly: '1',
- +encryptionFailed?: string,
- }
- | { +encryptedPayload: string },
- }>,
-};
-
-type AndroidNotificationWithPriority =
- | {
- +notification: AndroidVisualNotification,
- +priority: 'high',
- }
- | {
- +notification: AndroidBadgeOnlyNotification | AndroidNotificationRescind,
- +priority: 'normal',
- };
-
-export type TargetedAndroidNotification = $ReadOnly<{
- ...AndroidNotificationWithPriority,
- +deviceToken: string,
- +encryptionOrder?: number,
-}>;
-
-export type TargetedWebNotification = {
- +notification: WebNotification,
- +deviceToken: string,
- +encryptionOrder?: number,
-};
-
-export type TargetedWNSNotification = {
- +notification: WNSNotification,
- +deviceToken: string,
- +encryptionOrder?: number,
-};
-
-export type NotificationTargetDevice = {
- +cookieID: string,
- +deviceToken: string,
- +blobHolder?: string,
-};
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
@@ -9,6 +9,11 @@
import webpush from 'web-push';
import type { PlatformDetails } from 'lib/types/device-types.js';
+import type {
+ TargetedAndroidNotification,
+ TargetedWebNotification,
+ TargetedWNSNotification,
+} from 'lib/types/notif-types.js';
import { threadSubscriptions } from 'lib/types/subscription-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
@@ -21,12 +26,7 @@
ensureWebPushInitialized,
getWNSToken,
} from './providers.js';
-import type {
- TargetedAPNsNotification,
- TargetedAndroidNotification,
- TargetedWebNotification,
- TargetedWNSNotification,
-} from './types.js';
+import type { TargetedAPNsNotification } from './types.js';
import { dbQuery, SQL } from '../database/database.js';
import { upload, assignHolder } from '../services/blob.js';
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
@@ -73,3 +73,107 @@
export type WNSNotification =
| PlainTextWNSNotification
| EncryptedWNSNotification;
+
+export type AndroidVisualNotificationPayloadBase = $ReadOnly<{
+ +badge: string,
+ +body: string,
+ +title: string,
+ +prefix?: string,
+ +threadID: string,
+ +collapseKey?: string,
+ +badgeOnly?: '0',
+ +encryptionFailed?: '1',
+}>;
+
+export type AndroidVisualNotificationPayload = $ReadOnly<
+ | {
+ ...AndroidVisualNotificationPayloadBase,
+ +messageInfos?: string,
+ }
+ | {
+ ...AndroidVisualNotificationPayloadBase,
+ +blobHash: string,
+ +encryptionKey: string,
+ },
+>;
+
+export type AndroidVisualNotification = {
+ +data: $ReadOnly<{
+ +id?: string,
+ +keyserverID: string,
+ ...
+ | {
+ ...AndroidVisualNotificationPayloadBase,
+ +messageInfos?: string,
+ }
+ | {
+ ...AndroidVisualNotificationPayloadBase,
+ +blobHash: string,
+ +encryptionKey: string,
+ }
+ | { +encryptedPayload: string },
+ }>,
+};
+
+export type AndroidNotificationRescind = {
+ +data: $ReadOnly<{
+ +keyserverID: string,
+ ...
+ | {
+ +badge: string,
+ +rescind: 'true',
+ +rescindID: string,
+ +setUnreadStatus: 'true',
+ +threadID: string,
+ +encryptionFailed?: string,
+ }
+ | { +encryptedPayload: string },
+ }>,
+};
+
+export type AndroidBadgeOnlyNotification = {
+ +data: $ReadOnly<{
+ +keyserverID: string,
+ ...
+ | {
+ +badge: string,
+ +badgeOnly: '1',
+ +encryptionFailed?: string,
+ }
+ | { +encryptedPayload: string },
+ }>,
+};
+
+type AndroidNotificationWithPriority =
+ | {
+ +notification: AndroidVisualNotification,
+ +priority: 'high',
+ }
+ | {
+ +notification: AndroidBadgeOnlyNotification | AndroidNotificationRescind,
+ +priority: 'normal',
+ };
+
+export type TargetedAndroidNotification = $ReadOnly<{
+ ...AndroidNotificationWithPriority,
+ +deviceToken: string,
+ +encryptionOrder?: number,
+}>;
+
+export type TargetedWebNotification = {
+ +notification: WebNotification,
+ +deviceToken: string,
+ +encryptionOrder?: number,
+};
+
+export type TargetedWNSNotification = {
+ +notification: WNSNotification,
+ +deviceToken: string,
+ +encryptionOrder?: number,
+};
+
+export type NotificationTargetDevice = {
+ +cookieID: string,
+ +deviceToken: string,
+ +blobHolder?: string,
+};

File Metadata

Mime Type
text/plain
Expires
Sat, Sep 28, 3:24 PM (20 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2196984
Default Alt Text
D12394.diff (9 KB)

Event Timeline