Page MenuHomePhabricator

D13024.id43318.diff
No OneTemporary

D13024.id43318.diff

diff --git a/lib/components/peer-olm-session-creator-provider.react.js b/lib/components/peer-olm-session-creator-provider.react.js
--- a/lib/components/peer-olm-session-creator-provider.react.js
+++ b/lib/components/peer-olm-session-creator-provider.react.js
@@ -5,12 +5,16 @@
import { IdentityClientContext } from '../shared/identity-client-context.js';
import { useTunnelbroker } from '../tunnelbroker/tunnelbroker-context.js';
-import { createOlmSessionWithPeer } from '../utils/crypto-utils.js';
+import {
+ createOlmSessionWithPeer,
+ type SessionCreationOptions,
+} from '../utils/crypto-utils.js';
export type PeerOlmSessionCreatorContextType = {
+createOlmSessionsWithPeer: (
userID: string,
deviceID: string,
+ sessionCreationOptions?: SessionCreationOptions,
) => Promise<void>,
};
@@ -32,7 +36,11 @@
}>({});
const createOlmSessionsWithPeer = React.useCallback(
- (userID: string, deviceID: string) => {
+ (
+ userID: string,
+ deviceID: string,
+ sessionCreationOptions?: SessionCreationOptions,
+ ) => {
if (
runningPromises.current[userID] &&
runningPromises.current[userID][deviceID]
@@ -48,6 +56,7 @@
sendMessageToDevice,
userID,
deviceID,
+ sessionCreationOptions,
);
runningPromises.current[userID][deviceID] = null;
diff --git a/lib/utils/crypto-utils.js b/lib/utils/crypto-utils.js
--- a/lib/utils/crypto-utils.js
+++ b/lib/utils/crypto-utils.js
@@ -107,18 +107,33 @@
}
}
+export type SessionCreationOptions = {
+ +overwriteNotifSession?: boolean,
+ +overwriteContentSession?: boolean,
+};
async function createOlmSessionWithPeer(
authMetadata: AuthMetadata,
identityClient: IdentityServiceClient,
sendMessage: (message: TunnelbrokerClientMessageToDevice) => Promise<void>,
userID: string,
deviceID: string,
+ options?: SessionCreationOptions,
): Promise<void> {
const { olmAPI } = getConfig();
await olmAPI.initializeCryptoAccount();
const [hasContentSession, hasNotifsSession] = await Promise.all([
- olmAPI.isContentSessionInitialized(deviceID),
- olmAPI.isDeviceNotificationsSessionInitialized(deviceID),
+ (async () => {
+ if (options?.overwriteContentSession) {
+ return false;
+ }
+ return await olmAPI.isContentSessionInitialized(deviceID);
+ })(),
+ (async () => {
+ if (options?.overwriteNotifSession) {
+ return false;
+ }
+ return await olmAPI.isDeviceNotificationsSessionInitialized(deviceID);
+ })(),
]);
if (hasContentSession && hasNotifsSession) {

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 12:27 PM (19 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2600936
Default Alt Text
D13024.id43318.diff (2 KB)

Event Timeline