Skip to content

Commit 5a0dd1e

Browse files
committed
Ensure we check if the room is encrypted first.
1 parent 81e6824 commit 5a0dd1e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/appservice/Appservice.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,10 @@ export class Appservice extends EventEmitter {
671671
private async decryptAppserivceEvent(roomId: string, encrypted: EncryptedRoomEvent): ReturnType<Appservice["processEvent"]> {
672672
const existingClient = this.cryptoClientForRoomId.get(roomId);
673673
const decryptFn = async (client: MatrixClient) => {
674+
// Also fetches state in order to decrypt room. We should throw if the client is confused.
675+
if (!await client.crypto.isRoomEncrypted(roomId)) {
676+
throw new Error("Client detected that the room is not encrypted.")
677+
}
674678
let event = (await client.crypto.decryptRoomEvent(encrypted, roomId)).raw;
675679
event = await this.processEvent(event);
676680
this.cryptoClientForRoomId.set(roomId, client);

0 commit comments

Comments
 (0)