Store in DB events which failed to be decrypted

This commit is contained in:
Maxime NATUREL 2023-01-19 17:48:19 +01:00
parent 3ba2c47d1e
commit 6b6dea0c45
1 changed files with 4 additions and 1 deletions

View File

@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.session.room.event
import com.zhuinden.monarchy.Monarchy import com.zhuinden.monarchy.Monarchy
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.EventType
import org.matrix.android.sdk.api.session.room.send.SendState import org.matrix.android.sdk.api.session.room.send.SendState
import org.matrix.android.sdk.internal.crypto.EventDecryptor import org.matrix.android.sdk.internal.crypto.EventDecryptor
import org.matrix.android.sdk.internal.database.mapper.toEntity import org.matrix.android.sdk.internal.database.mapper.toEntity
@ -48,7 +49,9 @@ internal class DefaultFilterAndStoreEventsTask @Inject constructor(
override suspend fun execute(params: FilterAndStoreEventsTask.Params) { override suspend fun execute(params: FilterAndStoreEventsTask.Params) {
val filteredEvents = params.events val filteredEvents = params.events
.map { decryptEventIfNeeded(it) } .map { decryptEventIfNeeded(it) }
.filter { params.filterPredicate(it) } // we also filter in the encrypted events since it means there was decryption error for them
// and they may be decrypted later
.filter { params.filterPredicate(it) || it.getClearType() == EventType.ENCRYPTED }
addMissingEventsInDB(params.roomId, filteredEvents) addMissingEventsInDB(params.roomId, filteredEvents)
} }