From ee591714910f38915efb0d9a941b5e0b626c21b0 Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 12 Mar 2024 09:00:50 +0100 Subject: [PATCH] Fix StreamEventsManager not signaling event decryptions --- .../android/sdk/internal/crypto/DecryptRoomEventUseCase.kt | 6 ++++-- .../matrix/android/sdk/internal/crypto/RustCryptoService.kt | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DecryptRoomEventUseCase.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DecryptRoomEventUseCase.kt index 12255d0783..25a1ffc005 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DecryptRoomEventUseCase.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DecryptRoomEventUseCase.kt @@ -22,10 +22,12 @@ import org.matrix.android.sdk.api.session.crypto.model.OlmDecryptionResult import org.matrix.android.sdk.api.session.events.model.Event import javax.inject.Inject -internal class DecryptRoomEventUseCase @Inject constructor(private val olmMachine: OlmMachine) { +internal class DecryptRoomEventUseCase @Inject constructor( + private val cryptoService: RustCryptoService +) { suspend operator fun invoke(event: Event): MXEventDecryptionResult { - return olmMachine.decryptRoomEvent(event) + return cryptoService.decryptEvent(event, "") } suspend fun decryptAndSaveResult(event: Event) { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt index c0407ca4e8..5ba74f705b 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt @@ -497,8 +497,11 @@ internal class RustCryptoService @Inject constructor( @Throws(MXCryptoError::class) override suspend fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult { return try { - olmMachine.decryptRoomEvent(event) + olmMachine.decryptRoomEvent(event).also { + liveEventManager.get().dispatchLiveEventDecrypted(event, it) + } } catch (mxCryptoError: MXCryptoError) { + liveEventManager.get().dispatchLiveEventDecryptionFailed(event, mxCryptoError) if (mxCryptoError is MXCryptoError.Base && ( mxCryptoError.errorType == MXCryptoError.ErrorType.UNKNOWN_INBOUND_SESSION_ID || mxCryptoError.errorType == MXCryptoError.ErrorType.UNKNOWN_MESSAGE_INDEX)) {