From 26e34238cbbaf38dd34f4bd4d30380b558f9b6d5 Mon Sep 17 00:00:00 2001 From: Jacob Persson <7156+typfel@users.noreply.github.com> Date: Fri, 22 Sep 2023 21:01:19 +0200 Subject: [PATCH] fix: map and ignore BufferedFutureMessage --- .../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 520f03f1828..29c9cc7e869 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt @@ -172,6 +172,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