Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2894217
D8720.id29508.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D8720.id29508.diff
View Options
diff --git a/keyserver/src/creators/message-creator.js b/keyserver/src/creators/message-creator.js
--- a/keyserver/src/creators/message-creator.js
+++ b/keyserver/src/creators/message-creator.js
@@ -39,6 +39,7 @@
} from '../fetchers/message-fetchers.js';
import { fetchOtherSessionsForViewer } from '../fetchers/session-fetchers.js';
import { fetchServerThreadInfos } from '../fetchers/thread-fetchers.js';
+import type { Device } from '../push/send';
import { sendPushNotifs, sendRescindNotifs } from '../push/send.js';
import { handleAsyncPromise } from '../responders/handlers.js';
import type { Viewer } from '../session/viewer.js';
@@ -47,15 +48,7 @@
import { creationString } from '../utils/idempotent.js';
type UserThreadInfo = {
- +devices: Map<
- string,
- {
- +platform: string,
- +deviceToken: string,
- +cookieID: string,
- +codeVersion: ?string,
- },
- >,
+ +devices: Map<string, Device>,
+threadIDs: Set<string>,
+notFocusedThreadIDs: Set<string>,
+userNotMemberOfSubthreads: Set<string>,
@@ -391,6 +384,7 @@
deviceToken,
cookieID: cookieID.toString(),
codeVersion: versions ? versions.codeVersion : null,
+ stateVersion: versions ? versions.stateVersion : null,
});
}
thisUserInfo.threadIDs.add(threadID);
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
@@ -75,11 +75,12 @@
import { getENSNames } from '../utils/ens-cache.js';
import { validateOutput } from '../utils/validation-utils.js';
-type Device = {
+export type Device = {
+platform: Platform,
+deviceToken: string,
+cookieID: string,
+codeVersion: ?number,
+ +stateVersion: ?number,
};
type PushUserInfo = {
@@ -206,8 +207,14 @@
const iosVersionsToTokens = byPlatform.get('ios');
if (iosVersionsToTokens) {
- for (const [codeVersion, devices] of iosVersionsToTokens) {
- const platformDetails = { platform: 'ios', codeVersion };
+ for (const [versionKey, devices] of iosVersionsToTokens) {
+ const [codeVersion, stateVersion] = versionKey.split('|').map(Number);
+
+ const platformDetails: PlatformDetails = {
+ platform: 'ios',
+ codeVersion,
+ stateVersion,
+ };
const shimmedNewRawMessageInfos = shimUnsupportedRawMessageInfos(
newRawMessageInfos,
platformDetails,
@@ -235,8 +242,13 @@
}
const androidVersionsToTokens = byPlatform.get('android');
if (androidVersionsToTokens) {
- for (const [codeVersion, devices] of androidVersionsToTokens) {
- const platformDetails = { platform: 'android', codeVersion };
+ for (const [versionKey, devices] of androidVersionsToTokens) {
+ const [codeVersion, stateVersion] = versionKey.split('|').map(Number);
+ const platformDetails = {
+ platform: 'android',
+ codeVersion,
+ stateVersion,
+ };
const shimmedNewRawMessageInfos = shimUnsupportedRawMessageInfos(
newRawMessageInfos,
platformDetails,
@@ -265,8 +277,14 @@
}
const webVersionsToTokens = byPlatform.get('web');
if (webVersionsToTokens) {
- for (const [codeVersion, devices] of webVersionsToTokens) {
- const platformDetails = { platform: 'web', codeVersion };
+ for (const [versionKey, devices] of webVersionsToTokens) {
+ const [codeVersion, stateVersion] = versionKey.split('|').map(Number);
+ const platformDetails = {
+ platform: 'web',
+ codeVersion,
+ stateVersion,
+ };
+
const deliveryPromise = (async () => {
const notification = await prepareWebNotification({
notifTexts,
@@ -285,8 +303,13 @@
}
const macosVersionsToTokens = byPlatform.get('macos');
if (macosVersionsToTokens) {
- for (const [codeVersion, devices] of macosVersionsToTokens) {
- const platformDetails = { platform: 'macos', codeVersion };
+ for (const [versionKey, devices] of macosVersionsToTokens) {
+ const [codeVersion, stateVersion] = versionKey.split('|').map(Number);
+ const platformDetails = {
+ platform: 'macos',
+ codeVersion,
+ stateVersion,
+ };
const shimmedNewRawMessageInfos = shimUnsupportedRawMessageInfos(
newRawMessageInfos,
platformDetails,
@@ -314,8 +337,14 @@
}
const windowsVersionsToTokens = byPlatform.get('windows');
if (windowsVersionsToTokens) {
- for (const [codeVersion, devices] of windowsVersionsToTokens) {
- const platformDetails = { platform: 'windows', codeVersion };
+ for (const [versionKey, devices] of windowsVersionsToTokens) {
+ const [codeVersion, stateVersion] = versionKey.split('|').map(Number);
+ const platformDetails = {
+ platform: 'windows',
+ codeVersion,
+ stateVersion,
+ };
+
const deliveryPromise = (async () => {
const notification = await prepareWNSNotification({
notifTexts,
@@ -593,7 +622,7 @@
function getDevicesByPlatform(
devices: $ReadOnlyArray<Device>,
-): Map<Platform, Map<number, Array<NotificationTargetDevice>>> {
+): Map<Platform, Map<string, Array<NotificationTargetDevice>>> {
const byPlatform = new Map();
for (const device of devices) {
let innerMap = byPlatform.get(device.platform);
@@ -608,10 +637,12 @@
device.platform !== 'macos'
? device.codeVersion
: -1;
- let innerMostArray = innerMap.get(codeVersion);
+ const stateVersion: number = device.stateVersion ?? -1;
+ const versionKey = `${codeVersion}|${stateVersion}`;
+ let innerMostArray = innerMap.get(versionKey);
if (!innerMostArray) {
innerMostArray = [];
- innerMap.set(codeVersion, innerMostArray);
+ innerMap.set(versionKey, innerMostArray);
}
innerMostArray.push({
@@ -1224,11 +1255,13 @@
const iosVersionsToTokens = byPlatform.get('ios');
if (iosVersionsToTokens) {
- for (const [codeVersion, deviceInfos] of iosVersionsToTokens) {
+ for (const [versionKey, deviceInfos] of iosVersionsToTokens) {
+ const [codeVersion, stateVersion] = versionKey.split('|').map(Number);
const notification = new apn.Notification();
notification.topic = getAPNsNotificationTopic({
platform: 'ios',
codeVersion,
+ stateVersion,
});
notification.badge = unreadCount;
notification.pushType = 'alert';
@@ -1263,7 +1296,8 @@
const androidVersionsToTokens = byPlatform.get('android');
if (androidVersionsToTokens) {
- for (const [codeVersion, deviceInfos] of androidVersionsToTokens) {
+ for (const [versionKey, deviceInfos] of androidVersionsToTokens) {
+ const [codeVersion] = versionKey.split('|').map(Number);
const notificationData =
codeVersion < 69
? { badge: unreadCount.toString() }
@@ -1299,11 +1333,13 @@
const macosVersionsToTokens = byPlatform.get('macos');
if (macosVersionsToTokens) {
- for (const [codeVersion, deviceInfos] of macosVersionsToTokens) {
+ for (const [versionKey, deviceInfos] of macosVersionsToTokens) {
+ const [codeVersion, stateVersion] = versionKey.split('|').map(Number);
const notification = new apn.Notification();
notification.topic = getAPNsNotificationTopic({
platform: 'macos',
codeVersion,
+ stateVersion,
});
notification.badge = unreadCount;
notification.pushType = 'alert';
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 5, 3:10 PM (21 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2244269
Default Alt Text
D8720.id29508.diff (7 KB)
Attached To
Mode
D8720: [keyserver] Include stateVersion when converting notifications
Attached
Detach File
Event Timeline
Log In to Comment