Page MenuHomePhabricator

D13373.id44326.diff
No OneTemporary

D13373.id44326.diff

diff --git a/lib/push/send-utils.js b/lib/push/send-utils.js
--- a/lib/push/send-utils.js
+++ b/lib/push/send-utils.js
@@ -65,6 +65,7 @@
import type { DeviceSessionCreationRequest } from '../utils/crypto-utils.js';
import { type GetENSNames } from '../utils/ens-helpers.js';
import { type GetFCNames } from '../utils/farcaster-helpers.js';
+import { values } from '../utils/objects.js';
import { promiseAll } from '../utils/promises.js';
export type Device = {
@@ -963,8 +964,8 @@
}
async function createOlmSessionWithDevices(
- deviceIDsToUserIDs: {
- +[string]: string,
+ userDevices: {
+ +[userID: string]: $ReadOnlyArray<string>,
},
olmSessionCreator: (
userID: string,
@@ -979,17 +980,18 @@
const deviceIDsToSessionPresence =
await isNotificationsSessionInitializedWithDevices(
- Object.keys(deviceIDsToUserIDs),
+ values(userDevices).flat(),
);
const olmSessionCreationPromises = [];
- for (const deviceID in deviceIDsToSessionPresence) {
- if (deviceIDsToSessionPresence[deviceID]) {
- continue;
- }
- olmSessionCreationPromises.push(
- olmSessionCreator(deviceIDsToUserIDs[deviceID], [{ deviceID }]),
- );
+ for (const userID in userDevices) {
+ const devices = userDevices[userID]
+ .filter(deviceID => !deviceIDsToSessionPresence[deviceID])
+ .map(deviceID => ({
+ deviceID,
+ }));
+
+ olmSessionCreationPromises.push(olmSessionCreator(userID, devices));
}
try {
@@ -1079,14 +1081,16 @@
const filteredPushInfos = filterDevicesSupportingDMNotifsForUsers(pushInfos);
- const deviceIDsToUserIDs: { [string]: string } = {};
+ const userDevices: {
+ [userID: string]: $ReadOnlyArray<string>,
+ } = {};
for (const userID in filteredPushInfos) {
- for (const device of filteredPushInfos[userID].devices) {
- deviceIDsToUserIDs[device.cryptoID] = userID;
- }
+ userDevices[userID] = filteredPushInfos[userID].devices.map(
+ device => device.cryptoID,
+ );
}
- await createOlmSessionWithDevices(deviceIDsToUserIDs, olmSessionCreator);
+ await createOlmSessionWithDevices(userDevices, olmSessionCreator);
return await buildNotifsFromPushInfo({
encryptedNotifUtilsAPI,
@@ -1133,13 +1137,16 @@
filterDevicesSupportingDMNotifs(ownDevicesPushInfo);
const { senderUserID, senderDeviceDescriptor } = senderInfo;
- const deviceIDsToUserIDs: { [string]: string } = {};
- for (const device of filteredownDevicesPushInfos.devices) {
- deviceIDsToUserIDs[device.cryptoID] = senderUserID;
- }
+ const userDevices: {
+ +[userID: string]: $ReadOnlyArray<string>,
+ } = {
+ [senderUserID]: filteredownDevicesPushInfos.devices.map(
+ device => device.cryptoID,
+ ),
+ };
- await createOlmSessionWithDevices(deviceIDsToUserIDs, olmSessionCreator);
+ await createOlmSessionWithDevices(userDevices, olmSessionCreator);
const devicesByPlatform = getDevicesByPlatform(
filteredownDevicesPushInfos.devices,
);

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 11:27 AM (18 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2569359
Default Alt Text
D13373.id44326.diff (2 KB)

Event Timeline