Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #232 from matrixgpt/leave-room-on-crypto-error
Browse files Browse the repository at this point in the history
Leave room when room key error occurs.
  • Loading branch information
bertybuttface authored Oct 27, 2023
2 parents 7992942 + 1dca8d6 commit 5110281
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ async function main() {
client.on("room.failed_decryption", async (roomId, event, error) => {
// handle `m.room.encrypted` event that could not be decrypted
LogService.error("index", `Failed decryption event!\n${{ roomId, event, error }}`);
await client.sendText(roomId, `I couldn't decrypt the message :( Please add me to an unencrypted room.`);
await client.sendText(roomId, `Room key error. I will leave the room, please reinvite me!`);
try {
await client.leaveRoom(roomId);
} catch (e) {
LogService.error("index", `Failed to leave room ${roomId} after failed decryption!`);
}
});

client.on("room.join", async (roomId: string, _event: any) => {
Expand Down

0 comments on commit 5110281

Please sign in to comment.