Skip to content

Commit 0a112a4

Browse files
committed
Replace MatrixClient.isRoomEncrypted by MatrixClient.CryptoApi.isEncryptionEnabledInRoom in ContentMessages.ts
1 parent 06d1239 commit 0a112a4

3 files changed

Lines changed: 3 additions & 8 deletions

File tree

src/ContentMessages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ export async function uploadFile(
337337
const abortController = controller ?? new AbortController();
338338

339339
// If the room is encrypted then encrypt the file before uploading it.
340-
if (matrixClient.isRoomEncrypted(roomId)) {
340+
if (matrixClient.getCrypto()?.isEncryptionEnabledInRoom(roomId)) {
341341
// First read the file into memory.
342342
const data = await readFileAsArrayBuffer(file);
343343
if (abortController.signal.aborted) throw new UploadCanceledError();

test/test-utils/test-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export function createTestClient(): MatrixClient {
273273
isFallbackICEServerAllowed: jest.fn().mockReturnValue(false),
274274
getAuthIssuer: jest.fn(),
275275
getOrCreateFilter: jest.fn(),
276+
sendStickerMessage: jest.fn(),
276277
} as unknown as MatrixClient;
277278

278279
client.reEmitter = new ReEmitter(client);

test/unit-tests/ContentMessages-test.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,7 @@ describe("ContentMessages", () => {
4343
let prom: Promise<ISendEventResponse>;
4444

4545
beforeEach(() => {
46-
client = {
47-
getSafeUserId: jest.fn().mockReturnValue("@alice:test"),
48-
sendStickerMessage: jest.fn(),
49-
sendMessage: jest.fn(),
50-
isRoomEncrypted: jest.fn().mockReturnValue(false),
51-
uploadContent: jest.fn().mockResolvedValue({ content_uri: "mxc://server/file" }),
52-
} as unknown as MatrixClient;
46+
client = createTestClient();
5347
contentMessages = new ContentMessages();
5448
prom = Promise.resolve<ISendEventResponse>({ event_id: "$event_id" });
5549
});

0 commit comments

Comments
 (0)