You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-09 10:22:46 +03:00
Element-R: silence log errors when viewing a decryption failure (#3821)
This commit is contained in:
committed by
GitHub
parent
6e2ac03f7e
commit
12e479a93e
@@ -505,6 +505,26 @@ describe("RustCrypto", () => {
|
|||||||
expect(olmMachine.getRoomEventEncryptionInfo).not.toHaveBeenCalled();
|
expect(olmMachine.getRoomEventEncryptionInfo).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should handle decryption failures", async () => {
|
||||||
|
const event = mkEvent({
|
||||||
|
event: true,
|
||||||
|
type: "m.room.encrypted",
|
||||||
|
content: { algorithm: "fake_alg" },
|
||||||
|
room: "!room:id",
|
||||||
|
});
|
||||||
|
event.event.event_id = "$event:id";
|
||||||
|
const mockCryptoBackend = {
|
||||||
|
decryptEvent: () => {
|
||||||
|
throw new Error("UISI");
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await event.attemptDecryption(mockCryptoBackend as unknown as CryptoBackend);
|
||||||
|
|
||||||
|
const res = await rustCrypto.getEncryptionInfoForEvent(event);
|
||||||
|
expect(res).toBe(null);
|
||||||
|
expect(olmMachine.getRoomEventEncryptionInfo).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it("passes the event into the OlmMachine", async () => {
|
it("passes the event into the OlmMachine", async () => {
|
||||||
const encryptedEvent = await makeEncryptedEvent();
|
const encryptedEvent = await makeEncryptedEvent();
|
||||||
const res = await rustCrypto.getEncryptionInfoForEvent(encryptedEvent);
|
const res = await rustCrypto.getEncryptionInfoForEvent(encryptedEvent);
|
||||||
|
@@ -1649,7 +1649,7 @@ class EventDecryptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getEncryptionInfoForEvent(event: MatrixEvent): Promise<EventEncryptionInfo | null> {
|
public async getEncryptionInfoForEvent(event: MatrixEvent): Promise<EventEncryptionInfo | null> {
|
||||||
if (!event.getClearContent()) {
|
if (!event.getClearContent() || event.isDecryptionFailure()) {
|
||||||
// not successfully decrypted
|
// not successfully decrypted
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user