From 0a112a4620485b7e0839d5d5992c71315040ee29 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Fri, 18 Oct 2024 15:00:19 +0200 Subject: [PATCH] Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `ContentMessages.ts` --- src/ContentMessages.ts | 2 +- test/test-utils/test-utils.ts | 1 + test/unit-tests/ContentMessages-test.ts | 8 +------- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/ContentMessages.ts b/src/ContentMessages.ts index 07c5491f51d..eb9f37e8777 100644 --- a/src/ContentMessages.ts +++ b/src/ContentMessages.ts @@ -337,7 +337,7 @@ export async function uploadFile( const abortController = controller ?? new AbortController(); // If the room is encrypted then encrypt the file before uploading it. - if (matrixClient.isRoomEncrypted(roomId)) { + if (matrixClient.getCrypto()?.isEncryptionEnabledInRoom(roomId)) { // First read the file into memory. const data = await readFileAsArrayBuffer(file); if (abortController.signal.aborted) throw new UploadCanceledError(); diff --git a/test/test-utils/test-utils.ts b/test/test-utils/test-utils.ts index 43807eb0301..888bd20302f 100644 --- a/test/test-utils/test-utils.ts +++ b/test/test-utils/test-utils.ts @@ -273,6 +273,7 @@ export function createTestClient(): MatrixClient { isFallbackICEServerAllowed: jest.fn().mockReturnValue(false), getAuthIssuer: jest.fn(), getOrCreateFilter: jest.fn(), + sendStickerMessage: jest.fn(), } as unknown as MatrixClient; client.reEmitter = new ReEmitter(client); diff --git a/test/unit-tests/ContentMessages-test.ts b/test/unit-tests/ContentMessages-test.ts index a47a99d2920..f7fc2b3a4bb 100644 --- a/test/unit-tests/ContentMessages-test.ts +++ b/test/unit-tests/ContentMessages-test.ts @@ -43,13 +43,7 @@ describe("ContentMessages", () => { let prom: Promise; beforeEach(() => { - client = { - getSafeUserId: jest.fn().mockReturnValue("@alice:test"), - sendStickerMessage: jest.fn(), - sendMessage: jest.fn(), - isRoomEncrypted: jest.fn().mockReturnValue(false), - uploadContent: jest.fn().mockResolvedValue({ content_uri: "mxc://server/file" }), - } as unknown as MatrixClient; + client = createTestClient(); contentMessages = new ContentMessages(); prom = Promise.resolve({ event_id: "$event_id" }); });