diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt index 08c2a5bb477..376b4fb5b11 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt @@ -996,7 +996,8 @@ class UserSessionScope internal constructor( conversationGroupRepository, conversationRepository, messageRepository, - userRepository + userRepository, + systemMessageInserter ) private val oneOnOneResolver: OneOnOneResolver get() = OneOnOneResolverImpl( diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneMigrator.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneMigrator.kt index 5d240c9cf95..2022a62263f 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneMigrator.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneMigrator.kt @@ -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 @@ -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 = @@ -99,6 +101,12 @@ internal class OneOnOneMigratorImpl( userId = user.id ).map { mlsConversation + }.also { + systemMessageInserter.insertProtocolChangedSystemMessage( + conversationId = mlsConversation, + senderUserId = user.id, + protocol = Conversation.Protocol.MLS + ) } } } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneMigratorTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneMigratorTest.kt index f8249116d18..790559555ee 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneMigratorTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneMigratorTest.kt @@ -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 @@ -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, @@ -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() } } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneResolverTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneResolverTest.kt index 8625cd6ce7d..2e6ff9c4af6 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneResolverTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/mls/OneOnOneResolverTest.kt @@ -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 diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/MessageRepositoryArrangement.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/MessageRepositoryArrangement.kt index 41bdaecee5a..cf5e75ee568 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/MessageRepositoryArrangement.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/MessageRepositoryArrangement.kt @@ -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 @@ -35,6 +36,9 @@ internal interface MessageRepositoryArrangement { @Mock val messageRepository: MessageRepository + @Mock + val systemMessageInserter: SystemMessageInserter + fun withGetMessageById( result: Either, messageID: Matcher = any(), @@ -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, @@ -117,3 +122,4 @@ internal open class MessageRepositoryArrangementImpl : MessageRepositoryArrangem .thenReturn(result) } } +