From bcfb121215d649ffb87e480a74cf9b6a28f5b259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 29 Jun 2021 11:12:41 +0200 Subject: [PATCH] crypto: Prepare the verification service to allow starting short SAS flows --- .../verification/RustVerificationService.kt | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/RustVerificationService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/RustVerificationService.kt index c3ff64d01d..4ba58ab9fc 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/RustVerificationService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/RustVerificationService.kt @@ -248,22 +248,29 @@ constructor( otherDeviceId: String, transactionId: String? ): String? { - val flowId = transactionId ?: return null - // should check if already one (and cancel it) return if (method == VerificationMethod.SAS) { - val request = this.getVerificationRequest(otherUserId, flowId) + val request = transactionId?.let { this.getVerificationRequest(otherUserId, it) } - runBlocking { - val sas = request?.startSasVerification() + if (request != null) { + runBlocking { + val sas = request.startSasVerification() - if (sas != null) { - val sasTransaction = SasVerification(olmMachine.inner(), sas, requestSender, listeners) - dispatchTxAdded(sasTransaction) - sasTransaction.transactionId - } else { - null + if (sas != null) { + val sasTransaction = SasVerification(olmMachine.inner(), sas, requestSender, listeners) + dispatchTxAdded(sasTransaction) + sasTransaction.transactionId + } else { + null + } } + } else { + // This should start the short SAS flow, the one that doesn't start with + // a `m.key.verification.request`, Element web stopped doing this, might + // be wise do do so as well + // DeviceListBottomSheetViewModel triggers this, interestingly the method that + // triggers this is called `manuallyVerify()` + TODO() } } else { throw IllegalArgumentException("Unknown verification method")