You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-23 17:02:25 +03:00
Use a different error code for UTDs when user was not in the room (#4172)
* use a different error code for UTDs when user was not in the room * if user is invited, treat it as unexpected UTD
This commit is contained in:
@@ -18,6 +18,7 @@ import anotherjson from "another-json";
|
||||
import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm";
|
||||
|
||||
import type { IEventDecryptionResult, IMegolmSessionData } from "../@types/crypto";
|
||||
import { KnownMembership } from "../@types/membership";
|
||||
import type { IDeviceLists, IToDeviceEvent } from "../sync-accumulator";
|
||||
import type { IEncryptedEventInfo } from "../crypto/api";
|
||||
import { IContent, MatrixEvent, MatrixEventEvent } from "../models/event";
|
||||
@@ -1741,6 +1742,17 @@ class EventDecryptor {
|
||||
) {
|
||||
this.perSessionBackupDownloader.onDecryptionKeyMissingError(event.getRoomId()!, content.session_id!);
|
||||
|
||||
// If the server is telling us our membership at the time the event
|
||||
// was sent, and it isn't "join", we use a different error code.
|
||||
const membership = event.getMembershipAtEvent();
|
||||
if (membership && membership !== KnownMembership.Join && membership !== KnownMembership.Invite) {
|
||||
throw new DecryptionError(
|
||||
DecryptionFailureCode.HISTORICAL_MESSAGE_USER_NOT_JOINED,
|
||||
"This message was sent when we were not a member of the room.",
|
||||
errorDetails,
|
||||
);
|
||||
}
|
||||
|
||||
// If the event was sent before this device was created, we use some different error codes.
|
||||
if (event.getTs() <= this.olmMachine.deviceCreationTimeMs) {
|
||||
if (serverBackupInfo === null) {
|
||||
|
||||
Reference in New Issue
Block a user