Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore MLS error and use concurrent map in the sub conversation #2608

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ actual fun mapMLSException(exception: Exception): MLSFailure =
is CryptoError.StaleProposal -> MLSFailure.StaleProposal
is CryptoError.StaleCommit -> MLSFailure.StaleCommit
is CryptoError.ConversationAlreadyExists -> MLSFailure.ConversationAlreadyExists
is CryptoError.MessageEpochTooOld -> MLSFailure.MessageEpochTooOld
else -> MLSFailure.Generic(exception)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ interface MLSFailure : CoreFailure {
data object UnmergedPendingGroup : MLSFailure

data object ConversationAlreadyExists : MLSFailure

data object MessageEpochTooOld : MLSFailure
data object ConversationDoesNotSupportMLS : MLSFailure
data object StaleProposal : MLSFailure
data object StaleCommit : MLSFailure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package com.wire.kalium.logic.data.conversation
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.id.GroupID
import com.wire.kalium.logic.data.id.SubconversationId
import io.ktor.util.collections.ConcurrentMap
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock

Expand All @@ -35,7 +36,7 @@ interface SubconversationRepository {
class SubconversationRepositoryImpl : SubconversationRepository {

private val mutex = Mutex()
private val subconversations = mutableMapOf<Pair<ConversationId, SubconversationId>, GroupID>()
private val subconversations = ConcurrentMap<Pair<ConversationId, SubconversationId>, GroupID>()

override suspend fun insertSubconversation(conversationId: ConversationId, subconversationId: SubconversationId, groupId: GroupID) {
mutex.withLock {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,12 @@ class EventMapper(
id: String,
eventContentDTO: EventContentDTO.Conversation.NewMLSMessageDTO,
) = Event.Conversation.NewMLSMessage(
id,
eventContentDTO.qualifiedConversation.toModel(),
eventContentDTO.subconversation?.let { SubconversationId(it) },
eventContentDTO.qualifiedFrom.toModel(),
eventContentDTO.time,
eventContentDTO.message
id = id,
conversationId = eventContentDTO.qualifiedConversation.toModel(),
subconversationId = eventContentDTO.subconversation?.let { SubconversationId(it) },
senderUserId = eventContentDTO.qualifiedFrom.toModel(),
timestampIso = eventContentDTO.time,
content = eventContentDTO.message
)

private fun connectionUpdate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ internal object MLSMessageFailureHandler {
is MLSFailure.UnmergedPendingGroup -> MLSMessageFailureResolution.Ignore
is MLSFailure.StaleProposal -> MLSMessageFailureResolution.Ignore
is MLSFailure.StaleCommit -> MLSMessageFailureResolution.Ignore
is MLSFailure.MessageEpochTooOld -> MLSMessageFailureResolution.Ignore
else -> MLSMessageFailureResolution.InformUser
}
}
Expand Down
Loading