1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-23 17:02:25 +03:00

Write a log line when cancelling verification (#4828)

... in an attempt to figure out what might have caused a spurious cancellation
today
This commit is contained in:
Richard van der Hoff
2025-05-08 10:55:22 +01:00
committed by GitHub
parent 00bd7f0f02
commit bb9280ad6b
3 changed files with 29 additions and 43 deletions

View File

@@ -969,15 +969,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
);
return requests
.filter((request) => request.roomId === undefined)
.map(
(request) =>
new RustVerificationRequest(
this.olmMachine,
request,
this.outgoingRequestProcessor,
this._supportedVerificationMethods,
),
);
.map((request) => this.makeVerificationRequest(request));
}
/**
@@ -1002,12 +994,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
const request = requests.find((request) => request.roomId?.toString() === roomId);
if (request) {
return new RustVerificationRequest(
this.olmMachine,
request,
this.outgoingRequestProcessor,
this._supportedVerificationMethods,
);
return this.makeVerificationRequest(request);
}
}
@@ -1038,12 +1025,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
new RustSdkCryptoJs.EventId(eventId),
methods,
);
return new RustVerificationRequest(
this.olmMachine,
request,
this.outgoingRequestProcessor,
this._supportedVerificationMethods,
);
return this.makeVerificationRequest(request);
} finally {
userIdentity.free();
}
@@ -1114,12 +1096,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
this._supportedVerificationMethods.map(verificationMethodIdentifierToMethod),
);
await this.outgoingRequestProcessor.makeOutgoingRequest(outgoingRequest);
return new RustVerificationRequest(
this.olmMachine,
request,
this.outgoingRequestProcessor,
this._supportedVerificationMethods,
);
return this.makeVerificationRequest(request);
} finally {
userIdentity.free();
}
@@ -1152,12 +1129,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
this._supportedVerificationMethods.map(verificationMethodIdentifierToMethod),
);
await this.outgoingRequestProcessor.makeOutgoingRequest(outgoingRequest);
return new RustVerificationRequest(
this.olmMachine,
request,
this.outgoingRequestProcessor,
this._supportedVerificationMethods,
);
return this.makeVerificationRequest(request);
} finally {
device.free();
}
@@ -1667,15 +1639,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
);
if (request) {
this.emit(
CryptoEvent.VerificationRequestReceived,
new RustVerificationRequest(
this.olmMachine,
request,
this.outgoingRequestProcessor,
this._supportedVerificationMethods,
),
);
this.emit(CryptoEvent.VerificationRequestReceived, this.makeVerificationRequest(request));
} else {
// There are multiple reasons this can happen; probably the most likely is that the event is an
// in-room event which is too old.
@@ -1685,6 +1649,17 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
}
}
/** Utility function to wrap a rust `VerificationRequest` with our own {@link VerificationRequest}. */
private makeVerificationRequest(request: RustSdkCryptoJs.VerificationRequest): VerificationRequest {
return new RustVerificationRequest(
this.logger,
this.olmMachine,
request,
this.outgoingRequestProcessor,
this._supportedVerificationMethods,
);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Other public functions