refactor: StreamEventsManager report MXCryptoError instead of throwable

This commit is contained in:
Valere 2024-03-14 11:04:35 +01:00
parent 3fa3eb1129
commit 72d2199f1a
3 changed files with 6 additions and 3 deletions

View File

@ -16,6 +16,7 @@
package org.matrix.android.sdk.api.session package org.matrix.android.sdk.api.session
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
import org.matrix.android.sdk.api.session.events.model.Event import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.util.JsonDict import org.matrix.android.sdk.api.util.JsonDict
@ -27,7 +28,7 @@ interface LiveEventListener {
fun onEventDecrypted(event: Event, clearEvent: JsonDict) fun onEventDecrypted(event: Event, clearEvent: JsonDict)
fun onEventDecryptionError(event: Event, throwable: Throwable) fun onEventDecryptionError(event: Event, cryptoError: MXCryptoError)
fun onLiveToDeviceEvent(event: Event) fun onLiveToDeviceEvent(event: Event)

View File

@ -22,6 +22,7 @@ import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.session.LiveEventListener import org.matrix.android.sdk.api.session.LiveEventListener
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
import org.matrix.android.sdk.api.session.crypto.model.MXEventDecryptionResult import org.matrix.android.sdk.api.session.crypto.model.MXEventDecryptionResult
import org.matrix.android.sdk.api.session.events.model.Event import org.matrix.android.sdk.api.session.events.model.Event
import timber.log.Timber import timber.log.Timber
@ -75,7 +76,7 @@ internal class StreamEventsManager @Inject constructor() {
} }
} }
fun dispatchLiveEventDecryptionFailed(event: Event, error: Throwable) { fun dispatchLiveEventDecryptionFailed(event: Event, error: MXCryptoError) {
Timber.v("## dispatchLiveEventDecryptionFailed ${event.eventId}") Timber.v("## dispatchLiveEventDecryptionFailed ${event.eventId}")
coroutineScope.launch { coroutineScope.launch {
listeners.forEach { listeners.forEach {

View File

@ -18,6 +18,7 @@ package im.vector.app
import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.LiveEventListener import org.matrix.android.sdk.api.session.LiveEventListener
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
import org.matrix.android.sdk.api.session.events.model.Event import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.events.model.toModel
@ -84,7 +85,7 @@ class UISIDetector(private val timeoutMillis: Long = 30_000L) : LiveEventListene
} }
} }
override fun onEventDecryptionError(event: Event, throwable: Throwable) { override fun onEventDecryptionError(event: Event, cryptoError: MXCryptoError) {
val eventId = event.eventId val eventId = event.eventId
val roomId = event.roomId val roomId = event.roomId
if (!enabled || eventId == null || roomId == null) return if (!enabled || eventId == null || roomId == null) return