feat: Add a way to get a verification request by its transaction id

A client might find the need to get the verification request object by
its transaction id, to be able to e.g. display for in-room verification
an "accept verification request" button easily.
This commit is contained in:
Sorunome 2021-08-07 16:31:21 +02:00 committed by Marcus
parent 86041513f8
commit 98b0bd4322
2 changed files with 7 additions and 0 deletions

View File

@ -52,6 +52,8 @@ class KeyVerificationManager {
_requests[request.transactionId] = request;
}
KeyVerification getRequest(String requestId) => _requests[requestId];
Future<void> handleToDeviceEvent(ToDeviceEvent event) async {
if (!event.type.startsWith('m.key.verification.') ||
client.verificationMethods.isEmpty) {

View File

@ -128,6 +128,11 @@ void main() {
await sub.cancel();
expect(req2 != null, true);
expect(
client2.encryption.keyVerificationManager
.getRequest(req2.transactionId),
req2);
// send ready
FakeMatrixApi.calledEndpoints.clear();
await req2.acceptVerification();