Skip to content

Commit

Permalink
fix: Migration message not shown in 1:1 conversations (#3042)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohassine authored and yamilmedina committed Jan 9, 2025
1 parent 768b5d4 commit 43fbe32
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,8 @@ class UserSessionScope internal constructor(
conversationGroupRepository,
conversationRepository,
messageRepository,
userRepository
userRepository,
systemMessageInserter
)
private val oneOnOneResolver: OneOnOneResolver
get() = OneOnOneResolverImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.wire.kalium.logic.data.conversation.ConversationGroupRepository
import com.wire.kalium.logic.data.conversation.ConversationRepository
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.message.MessageRepository
import com.wire.kalium.logic.data.message.SystemMessageInserter
import com.wire.kalium.logic.data.user.OtherUser
import com.wire.kalium.logic.data.user.UserRepository
import com.wire.kalium.logic.data.user.type.isTeammate
Expand Down Expand Up @@ -56,7 +57,8 @@ internal class OneOnOneMigratorImpl(
private val conversationGroupRepository: ConversationGroupRepository,
private val conversationRepository: ConversationRepository,
private val messageRepository: MessageRepository,
private val userRepository: UserRepository
private val userRepository: UserRepository,
private val systemMessageInserter: SystemMessageInserter
) : OneOnOneMigrator {

override suspend fun migrateToProteus(user: OtherUser): Either<CoreFailure, ConversationId> =
Expand Down Expand Up @@ -99,6 +101,12 @@ internal class OneOnOneMigratorImpl(
userId = user.id
).map {
mlsConversation
}.also {
systemMessageInserter.insertProtocolChangedSystemMessage(
conversationId = mlsConversation,
senderUserId = user.id,
protocol = Conversation.Protocol.MLS
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ import com.wire.kalium.logic.util.arrangement.repository.UserRepositoryArrangeme
import com.wire.kalium.logic.util.shouldFail
import com.wire.kalium.logic.util.shouldSucceed
import io.mockative.any
import io.mockative.coVerify
import io.mockative.eq
import io.mockative.once
import io.mockative.verify
import io.mockative.verify
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down Expand Up @@ -293,7 +291,7 @@ class OneOnOneMigratorTest {
ConversationRepositoryArrangement by ConversationRepositoryArrangementImpl(),
ConversationGroupRepositoryArrangement by ConversationGroupRepositoryArrangementImpl(),
UserRepositoryArrangement by UserRepositoryArrangementImpl() {
fun arrange() = run {
suspend fun arrange() = run {
block()
this@Arrangement to OneOnOneMigratorImpl(
getResolvedMLSOneOnOne = mlsOneOnOneConversationResolver,
Expand All @@ -307,6 +305,6 @@ class OneOnOneMigratorTest {
}

private companion object {
fun arrange(configuration: Arrangement.() -> Unit) = Arrangement(configuration).arrange()
suspend fun arrange(configuration: Arrangement.() -> Unit) = Arrangement(configuration).arrange()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import com.wire.kalium.logic.util.arrangement.repository.UserRepositoryArrangeme
import com.wire.kalium.logic.util.shouldFail
import com.wire.kalium.logic.util.shouldSucceed
import io.mockative.any
import io.mockative.coVerify
import io.mockative.eq
import io.mockative.given
import io.mockative.matchers.OneOfMatcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.wire.kalium.logic.StorageFailure
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.message.Message
import com.wire.kalium.logic.data.message.MessageRepository
import com.wire.kalium.logic.data.message.SystemMessageInserter
import com.wire.kalium.logic.data.notification.LocalNotification
import com.wire.kalium.logic.functional.Either
import io.mockative.Mock
Expand All @@ -35,6 +36,9 @@ internal interface MessageRepositoryArrangement {
@Mock
val messageRepository: MessageRepository

@Mock
val systemMessageInserter: SystemMessageInserter

fun withGetMessageById(
result: Either<StorageFailure, Message>,
messageID: Matcher<String> = any(),
Expand Down Expand Up @@ -65,6 +69,7 @@ internal interface MessageRepositoryArrangement {
internal open class MessageRepositoryArrangementImpl : MessageRepositoryArrangement {
@Mock
override val messageRepository: MessageRepository = mock(MessageRepository::class)
override val systemMessageInserter = mock(SystemMessageInserter::class)

override fun withGetMessageById(
result: Either<StorageFailure, Message>,
Expand Down Expand Up @@ -117,3 +122,4 @@ internal open class MessageRepositoryArrangementImpl : MessageRepositoryArrangem
.thenReturn(result)
}
}

0 comments on commit 43fbe32

Please sign in to comment.