From 6bce3d513d8bc5e13909d2fa1621e9b0cc8b7504 Mon Sep 17 00:00:00 2001 From: Jorge Martin Espinosa Date: Tue, 19 Nov 2024 13:58:13 +0100 Subject: [PATCH] Instantiate the verification controller ASAP (#3893) * Instantiate the verification controller when possible This is needed to get incoming verification requests * Workaround test failure --- .../verification/RustSessionVerificationService.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/verification/RustSessionVerificationService.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/verification/RustSessionVerificationService.kt index ed3ddec98b..84435119c0 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/verification/RustSessionVerificationService.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/verification/RustSessionVerificationService.kt @@ -96,6 +96,17 @@ class RustSessionVerificationService( private var listener: SessionVerificationServiceListener? = null + init { + // Instantiate the verification controller when possible, this is needed to get incoming verification requests + sessionCoroutineScope.launch { + // Needed to avoid crashes on unit tests due to the Rust SDK not being available + tryOrNull { + encryptionService.waitForE2eeInitializationTasks() + initVerificationControllerIfNeeded() + } + } + } + override fun setListener(listener: SessionVerificationServiceListener?) { this.listener = listener }