* Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `DeviceListener.ts` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `Searching.ts` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `SlidingSyncManager.ts` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `EncryptionEvent.tsx` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `ReportEventDialog.tsx` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `RoomNotifications.tsx` * Fix MessagePanel-test.tsx * ReplaceReplace `MatrixCient..isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `shouldSkipSetupEncryption.ts` * Add missing `await` * Use `Promise.any` instead of `asyncSome` * Add `asyncSomeParallel` * Use `asyncSomeParallel` instead of `asyncSome`
29 lines
1,007 B
TypeScript
29 lines
1,007 B
TypeScript
/*
|
|
Copyright 2024 New Vector Ltd.
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
|
|
|
import { shouldForceDisableEncryption } from "./shouldForceDisableEncryption";
|
|
import { asyncSomeParallel } from "../arrays.ts";
|
|
|
|
/**
|
|
* If encryption is force disabled AND the user is not in any encrypted rooms
|
|
* skip setting up encryption
|
|
* @param client
|
|
* @returns {boolean} true when we can skip settings up encryption
|
|
*/
|
|
export const shouldSkipSetupEncryption = async (client: MatrixClient): Promise<boolean> => {
|
|
const isEncryptionForceDisabled = shouldForceDisableEncryption(client);
|
|
const crypto = client.getCrypto();
|
|
if (!crypto) return true;
|
|
|
|
return (
|
|
isEncryptionForceDisabled &&
|
|
!(await asyncSomeParallel(client.getRooms(), ({ roomId }) => crypto.isEncryptionEnabledInRoom(roomId)))
|
|
);
|
|
};
|