From 51fdccb3930fb10b04d88ecd1a7754a834a07ba8 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 18 Jul 2019 09:29:27 +0200 Subject: [PATCH] cleaning --- .../room/EventRelationsAggregationTask.kt | 3 ++- .../action/ViewEditHistoryViewModel.kt | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/EventRelationsAggregationTask.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/EventRelationsAggregationTask.kt index f8c1024d2a..867ca2874f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/EventRelationsAggregationTask.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/EventRelationsAggregationTask.kt @@ -118,7 +118,8 @@ internal class DefaultEventRelationsAggregationTask @Inject constructor( forwardingCurve25519KeyChain = result.forwardingCurve25519KeyChain ) } catch (e: MXCryptoError) { - + Timber.w("Failed to decrypt e2e replace") + //TODO -> we should keep track of this and retry, or aggregation will be broken } } event.getClearContent().toModel()?.let { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/ViewEditHistoryViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/ViewEditHistoryViewModel.kt index cde65463d7..6ad172101a 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/ViewEditHistoryViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/ViewEditHistoryViewModel.kt @@ -28,6 +28,7 @@ import im.vector.matrix.android.api.session.room.model.message.isReply import im.vector.matrix.android.internal.crypto.algorithms.olm.OlmDecryptionResult import im.vector.riotx.core.platform.VectorViewModel import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineDateFormatter +import timber.log.Timber import java.util.* @@ -84,27 +85,27 @@ class ViewEditHistoryViewModel @AssistedInject constructor(@Assisted override fun onSuccess(data: List) { var originalIsReply = false - val events = data.map { - val timelineID = it.roomId + UUID.randomUUID().toString() - it.apply { + val events = data.map { event -> + val timelineID = event.roomId + UUID.randomUUID().toString() + event.also { //We need to check encryption - if (isEncrypted() && mxDecryptionResult == null) { + if (it.isEncrypted() && it.mxDecryptionResult == null) { //for now decrypt sync try { - val result = session.decryptEvent(this, timelineID) - mxDecryptionResult = OlmDecryptionResult( + val result = session.decryptEvent(it, timelineID) + it.mxDecryptionResult = OlmDecryptionResult( payload = result.clearEvent, senderKey = result.senderCurve25519Key, keysClaimed = result.claimedEd25519Key?.let { k -> mapOf("ed25519" to k) }, forwardingCurve25519KeyChain = result.forwardingCurve25519KeyChain ) } catch (e: MXCryptoError) { - + Timber.w("Failed to decrypt event in history") } } - if (it.eventId == eventId) { - originalIsReply = getClearContent().toModel().isReply() + if (event.eventId == it.eventId) { + originalIsReply = it.getClearContent().toModel().isReply() } }