From d5c1ddabfd93d359f5cdc6a9c34e61873504a9ef Mon Sep 17 00:00:00 2001 From: Jacob Persson <7156+typfel@users.noreply.github.com> Date: Tue, 26 Sep 2023 08:21:25 +0200 Subject: [PATCH] fix: map and ignore BufferedFutureMessage (#2084) --- .../com/wire/kalium/logic/CoreCryptoExceptionMapper.kt | 1 + .../commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt | 2 ++ .../conversation/message/MLSMessageFailureHandler.kt | 6 ++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/CoreCryptoExceptionMapper.kt b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/CoreCryptoExceptionMapper.kt index 97cd5ceac2e..935c35efebc 100644 --- a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/CoreCryptoExceptionMapper.kt +++ b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/CoreCryptoExceptionMapper.kt @@ -25,6 +25,7 @@ actual fun mapMLSException(exception: Exception): MLSFailure = when (exception.error) { is CryptoError.WrongEpoch -> MLSFailure.WrongEpoch is CryptoError.DuplicateMessage -> MLSFailure.DuplicateMessage + is CryptoError.BufferedFutureMessage -> MLSFailure.BufferedFutureMessage is CryptoError.SelfCommitIgnored -> MLSFailure.SelfCommitIgnored is CryptoError.UnmergedPendingGroup -> MLSFailure.UnmergedPendingGroup is CryptoError.ConversationAlreadyExists -> MLSFailure.ConversationAlreadyExists diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt index f604af891d7..18105b60ae3 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt @@ -173,6 +173,8 @@ interface MLSFailure : CoreFailure { object DuplicateMessage : MLSFailure + object BufferedFutureMessage : MLSFailure + object SelfCommitIgnored : MLSFailure object UnmergedPendingGroup : MLSFailure diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/message/MLSMessageFailureHandler.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/message/MLSMessageFailureHandler.kt index 9ba841c7bc4..85bcddeaa35 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/message/MLSMessageFailureHandler.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/message/MLSMessageFailureHandler.kt @@ -29,11 +29,13 @@ sealed class MLSMessageFailureResolution { internal object MLSMessageFailureHandler { fun handleFailure(failure: CoreFailure): MLSMessageFailureResolution { return when (failure) { - // Received messages targeting a future epoch, we might have lost messages. + // Received messages targeting a future epoch (outside epoch bounds), we might have lost messages. is MLSFailure.WrongEpoch -> MLSMessageFailureResolution.OutOfSync // Received already sent or received message, can safely be ignored. is MLSFailure.DuplicateMessage -> MLSMessageFailureResolution.Ignore - // Received self commit, any unmerged group has know when merged by CoreCrypto. + // Received message was targeting a future epoch and been buffered, can safely be ignored. + is MLSFailure.BufferedFutureMessage -> MLSMessageFailureResolution.Ignore + // Received self commit, any unmerged group has know been when merged by CoreCrypto. is MLSFailure.SelfCommitIgnored -> MLSMessageFailureResolution.Ignore // Message arrive in an unmerged group, it has been buffered and will be consumed later. is MLSFailure.UnmergedPendingGroup -> MLSMessageFailureResolution.Ignore