From 5fa0b4fbf2f80e69e223fdfd6a568a8c821ac8e8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 09:02:36 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20cleanup=20MLSCallHelper=20class=20(WPB?= =?UTF-8?q?-7153)=20-=20cherrypick=20RC=20=F0=9F=8D=92=20(#2959)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Commit with unresolved merge conflicts * chore: resolve conflicts * chore: resolve conflicts --------- Co-authored-by: Oussama Hassine --- .../logic/feature/call/CallManagerImpl.kt | 6 ++--- .../feature/call/scenario/OnCloseCall.kt | 6 ++--- .../call/scenario/OnParticipantListChanged.kt | 8 +++---- .../call/{MLSCallHelper.kt => CallHelper.kt} | 23 ++++++++++--------- ...MLSCallHelperTest.kt => CallHelperTest.kt} | 4 ++-- .../feature/call/scenario/OnCloseCallTest.kt | 9 ++++---- .../scenario/OnParticipantListChangedTest.kt | 8 +++---- 7 files changed, 32 insertions(+), 32 deletions(-) rename logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/{MLSCallHelper.kt => CallHelper.kt} (85%) rename logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/{MLSCallHelperTest.kt => CallHelperTest.kt} (99%) diff --git a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/CallManagerImpl.kt b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/CallManagerImpl.kt index 51fec13409e..d00225033e7 100644 --- a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/CallManagerImpl.kt +++ b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/CallManagerImpl.kt @@ -35,13 +35,13 @@ import com.wire.kalium.logic.callingLogger import com.wire.kalium.logic.configuration.UserConfigRepository import com.wire.kalium.logic.data.call.CallClient import com.wire.kalium.logic.data.call.CallClientList +import com.wire.kalium.logic.data.call.CallHelperImpl import com.wire.kalium.logic.data.call.CallRepository import com.wire.kalium.logic.data.call.CallStatus import com.wire.kalium.logic.data.call.CallType import com.wire.kalium.logic.data.call.EpochInfo import com.wire.kalium.logic.data.call.Participant import com.wire.kalium.logic.data.call.TestVideoType -import com.wire.kalium.logic.data.call.MLSCallHelperImpl import com.wire.kalium.logic.data.call.VideoState import com.wire.kalium.logic.data.call.VideoStateChecker import com.wire.kalium.logic.data.call.mapper.CallMapper @@ -216,7 +216,7 @@ class CallManagerImpl internal constructor( .keepingStrongReference(), closeCallHandler = OnCloseCall( callRepository = callRepository, - mlsCallHelper = MLSCallHelperImpl(callRepository, subconversationRepository, userConfigRepository), + callHelper = CallHelperImpl(callRepository, subconversationRepository, userConfigRepository), networkStateObserver = networkStateObserver, scope = scope, qualifiedIdMapper = qualifiedIdMapper @@ -543,7 +543,7 @@ class CallManagerImpl internal constructor( qualifiedIdMapper = qualifiedIdMapper, participantMapper = ParticipantMapperImpl(videoStateChecker, callMapper, qualifiedIdMapper), userConfigRepository = userConfigRepository, - mlsCallHelper = MLSCallHelperImpl( + callHelper = CallHelperImpl( callRepository = callRepository, subconversationRepository = subconversationRepository, userConfigRepository = userConfigRepository diff --git a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/scenario/OnCloseCall.kt b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/scenario/OnCloseCall.kt index a5098b2d078..60aaa94012f 100644 --- a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/scenario/OnCloseCall.kt +++ b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/scenario/OnCloseCall.kt @@ -28,7 +28,7 @@ import com.wire.kalium.logger.obfuscateId import com.wire.kalium.logic.callingLogger import com.wire.kalium.logic.data.call.CallRepository import com.wire.kalium.logic.data.call.CallStatus -import com.wire.kalium.logic.data.call.MLSCallHelper +import com.wire.kalium.logic.data.call.CallHelper import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.data.id.QualifiedIdMapper @@ -40,7 +40,7 @@ import kotlinx.coroutines.launch @Suppress("LongParameterList") class OnCloseCall( private val callRepository: CallRepository, - private val mlsCallHelper: MLSCallHelper, + private val callHelper: CallHelper, private val scope: CoroutineScope, private val qualifiedIdMapper: QualifiedIdMapper, private val networkStateObserver: NetworkStateObserver @@ -79,7 +79,7 @@ class OnCloseCall( callRepository.getCallMetadataProfile()[conversationIdWithDomain]?.conversationType if (callRepository.getCallMetadataProfile()[conversationIdWithDomain]?.protocol is Conversation.ProtocolInfo.MLS) { - mlsCallHelper.handleCallTermination(conversationIdWithDomain, conversationType) + callHelper.handleCallTermination(conversationIdWithDomain, conversationType) } callingLogger.i("[OnCloseCall] -> ConversationId: ${conversationId.obfuscateId()} | callStatus: $callStatus") } diff --git a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/scenario/OnParticipantListChanged.kt b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/scenario/OnParticipantListChanged.kt index 8e55d3ba891..a9836ef78dc 100644 --- a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/scenario/OnParticipantListChanged.kt +++ b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/scenario/OnParticipantListChanged.kt @@ -22,10 +22,10 @@ import com.sun.jna.Pointer import com.wire.kalium.calling.callbacks.ParticipantChangedHandler import com.wire.kalium.logger.obfuscateId import com.wire.kalium.logic.callingLogger -import com.wire.kalium.logic.configuration.UserConfigRepository import com.wire.kalium.logic.data.call.CallParticipants +import com.wire.kalium.logic.configuration.UserConfigRepository import com.wire.kalium.logic.data.call.CallRepository -import com.wire.kalium.logic.data.call.MLSCallHelper +import com.wire.kalium.logic.data.call.CallHelper import com.wire.kalium.logic.data.call.ParticipantMinimized import com.wire.kalium.logic.data.call.mapper.ParticipantMapper import com.wire.kalium.logic.data.id.ConversationId @@ -43,7 +43,7 @@ class OnParticipantListChanged internal constructor( private val qualifiedIdMapper: QualifiedIdMapper, private val participantMapper: ParticipantMapper, private val userConfigRepository: UserConfigRepository, - private val mlsCallHelper: MLSCallHelper, + private val callHelper: CallHelper, private val endCall: suspend (conversationId: ConversationId) -> Unit, private val callingScope: CoroutineScope, private val jsonDecoder: Json = Json @@ -67,7 +67,7 @@ class OnParticipantListChanged internal constructor( val currentCall = callRepository.establishedCallsFlow().first().firstOrNull() currentCall?.let { - val shouldEndSFTOneOnOneCall = mlsCallHelper.shouldEndSFTOneOnOneCall( + val shouldEndSFTOneOnOneCall = callHelper.shouldEndSFTOneOnOneCall( conversationId = conversationIdWithDomain, callProtocol = callProtocol, conversationType = it.conversationType, diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/MLSCallHelper.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/CallHelper.kt similarity index 85% rename from logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/MLSCallHelper.kt rename to logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/CallHelper.kt index 131478e1665..8759f162721 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/MLSCallHelper.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/CallHelper.kt @@ -30,13 +30,14 @@ import com.wire.kalium.logic.functional.onSuccess import com.wire.kalium.network.api.authenticated.conversation.SubconversationDeleteRequest /** - * Helper class to handle MLS call related operations. + * Helper class to handle call related operations. */ -interface MLSCallHelper { +interface CallHelper { /** - * Check if the OneOnOne MLS call that uses SFT should be ended. - * The call should be ended if the call has two participants and the second participant has lost audio. + * Check if the OneOnOne call that uses SFT should be ended. + * For Proteus, the call should be ended if the call has one participant after having 2 in the call. + * For MLS, the call should be ended if the call has two participants and the second participant has lost audio. * * @param conversationId the conversation id. * @param callProtocol the call protocol. @@ -55,7 +56,7 @@ interface MLSCallHelper { /** * Handle the call termination. - * If the call is a one on one call is oneOneOne on SFT, then delete MLS sub conversation + * If the call is oneOneOne on SFT, then delete MLS sub conversation * otherwise leave the MLS conference. * * @param conversationId the conversation id. @@ -68,11 +69,11 @@ interface MLSCallHelper { ) } -class MLSCallHelperImpl( +class CallHelperImpl( private val callRepository: CallRepository, private val subconversationRepository: SubconversationRepository, private val userConfigRepository: UserConfigRepository -) : MLSCallHelper { +) : CallHelper { override fun shouldEndSFTOneOnOneCall( conversationId: ConversationId, @@ -100,12 +101,12 @@ class MLSCallHelperImpl( if (userConfigRepository.shouldUseSFTForOneOnOneCalls().getOrElse(false) && conversationType == Conversation.Type.ONE_ON_ONE ) { - callingLogger.i("[MLSCallHelper] -> fetching remote MLS sub conversation details") + callingLogger.i("[CallHelper] -> fetching remote MLS sub conversation details") subconversationRepository.fetchRemoteSubConversationDetails( conversationId, CALL_SUBCONVERSATION_ID ).onSuccess { subconversationDetails -> - callingLogger.i("[MLSCallHelper] -> Deleting remote MLS sub conversation") + callingLogger.i("[CallHelper] -> Deleting remote MLS sub conversation") subconversationRepository.deleteRemoteSubConversation( subconversationDetails.parentId.toModel(), SubconversationId(subconversationDetails.id), @@ -115,10 +116,10 @@ class MLSCallHelperImpl( ) ) }.onFailure { - callingLogger.e("[MLSCallHelper] -> Error fetching remote MLS sub conversation details") + callingLogger.e("[CallHelper] -> Error fetching remote MLS sub conversation details") } } else { - callingLogger.i("[MLSCallHelper] -> Leaving MLS conference") + callingLogger.i("[CallHelper] -> Leaving MLS conference") callRepository.leaveMlsConference(conversationId) } } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/MLSCallHelperTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/CallHelperTest.kt similarity index 99% rename from logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/MLSCallHelperTest.kt rename to logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/CallHelperTest.kt index 880e39526e9..6b515cd2d4d 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/MLSCallHelperTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/CallHelperTest.kt @@ -44,7 +44,7 @@ import kotlin.test.Test import kotlin.test.assertFalse import kotlin.test.assertTrue -class MLSCallHelperTest { +class CallHelperTest { @Test fun givenMlsProtocol_whenShouldEndSFTOneOnOneCallIsCalled_thenReturnCorrectValue() = @@ -194,7 +194,7 @@ class MLSCallHelperTest { @Mock val userConfigRepository = mock(classOf()) - private val mLSCallHelper: MLSCallHelper = MLSCallHelperImpl( + private val mLSCallHelper: CallHelper = CallHelperImpl( callRepository = callRepository, subconversationRepository = subconversationRepository, userConfigRepository = userConfigRepository diff --git a/logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnCloseCallTest.kt b/logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnCloseCallTest.kt index 48fa46037bc..e3f7f6162bc 100644 --- a/logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnCloseCallTest.kt +++ b/logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnCloseCallTest.kt @@ -19,11 +19,11 @@ package com.wire.kalium.logic.feature.call.scenario import com.wire.kalium.calling.CallClosedReason import com.wire.kalium.calling.types.Uint32_t +import com.wire.kalium.logic.data.call.CallHelper import com.wire.kalium.logic.data.call.CallMetadata import com.wire.kalium.logic.data.call.CallMetadataProfile import com.wire.kalium.logic.data.call.CallRepository import com.wire.kalium.logic.data.call.CallStatus -import com.wire.kalium.logic.data.call.MLSCallHelper import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.data.id.GroupID @@ -40,7 +40,6 @@ import io.mockative.eq import io.mockative.every import io.mockative.mock import io.mockative.once -import io.mockative.verify import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest @@ -58,7 +57,7 @@ class OnCloseCallTest { val networkStateObserver = mock(NetworkStateObserver::class) @Mock - val mlsCallHelper = mock(classOf()) + val callHelper = mock(classOf()) val qualifiedIdMapper = QualifiedIdMapperImpl(TestUser.SELF.id) @@ -72,7 +71,7 @@ class OnCloseCallTest { fun setUp() { onCloseCall = OnCloseCall( callRepository, - mlsCallHelper, + callHelper, testScope, qualifiedIdMapper, networkStateObserver @@ -316,7 +315,7 @@ class OnCloseCallTest { }.wasInvoked(once) coVerify { - mlsCallHelper.handleCallTermination(eq(conversationId), any()) + callHelper.handleCallTermination(eq(conversationId), any()) }.wasInvoked(once) } diff --git a/logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnParticipantListChangedTest.kt b/logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnParticipantListChangedTest.kt index e44d4c5410b..c150f92aa97 100644 --- a/logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnParticipantListChangedTest.kt +++ b/logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnParticipantListChangedTest.kt @@ -22,7 +22,7 @@ import com.wire.kalium.logic.configuration.UserConfigRepository import com.wire.kalium.logic.data.call.Call import com.wire.kalium.logic.data.call.CallRepository import com.wire.kalium.logic.data.call.CallStatus -import com.wire.kalium.logic.data.call.MLSCallHelper +import com.wire.kalium.logic.data.call.CallHelper import com.wire.kalium.logic.data.call.ParticipantMinimized import com.wire.kalium.logic.data.call.mapper.ParticipantMapper import com.wire.kalium.logic.data.conversation.Conversation @@ -137,7 +137,7 @@ class OnParticipantListChangedTest { val userConfigRepository = mock(UserConfigRepository::class) @Mock - val mlsCallHelper = mock(MLSCallHelper::class) + val callHelper = mock(CallHelper::class) var isEndCallInvoked = false @@ -147,7 +147,7 @@ class OnParticipantListChangedTest { callRepository = callRepository, participantMapper = participantMapper, userConfigRepository = userConfigRepository, - mlsCallHelper = mlsCallHelper, + callHelper = callHelper, qualifiedIdMapper = qualifiedIdMapper, endCall = { isEndCallInvoked = true @@ -181,7 +181,7 @@ class OnParticipantListChangedTest { fun withShouldEndSFTOneOnOneCall(result: Boolean) = apply { every { - mlsCallHelper.shouldEndSFTOneOnOneCall(any(), any(), any(), any(), any()) + callHelper.shouldEndSFTOneOnOneCall(any(), any(), any(), any(), any()) }.returns(result) } }