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 0404843f7cb..a8a1279b941 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 @@ -37,7 +37,7 @@ 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.MLSCallHelperImpl +import com.wire.kalium.logic.data.call.CallHelperImpl 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 @@ -198,7 +198,7 @@ class CallManagerImpl internal constructor( .keepingStrongReference(), closeCallHandler = OnCloseCall( callRepository = callRepository, - mlsCallHelper = MLSCallHelperImpl( + callHelper = CallHelperImpl( callRepository = callRepository, subconversationRepository = subconversationRepository, userConfigRepository = userConfigRepository @@ -478,7 +478,7 @@ class CallManagerImpl internal constructor( participantMapper = ParticipantMapperImpl(videoStateChecker, callMapper), userRepository = userRepository, 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 504890d00ff..359f9f103dc 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 @@ -26,7 +26,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 @@ -36,7 +36,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 ) : CloseCallHandler { @@ -73,7 +73,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 18995e095bb..3d28055c09a 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 @@ -25,7 +25,7 @@ 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.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.Participant import com.wire.kalium.logic.data.call.mapper.ParticipantMapper import com.wire.kalium.logic.data.id.ConversationId @@ -47,7 +47,7 @@ class OnParticipantListChanged internal constructor( private val participantMapper: ParticipantMapper, private val userRepository: UserRepository, 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 @@ -81,7 +81,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 84% 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 da1988e4270..7f481e81c72 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.base.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/MLSCallHelperTest.kt index 8b6e1775245..2a8317b80b7 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/MLSCallHelperTest.kt @@ -197,7 +197,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 10024bf2fcd..4db4bcfcba5 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 @@ -27,9 +27,8 @@ import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.data.id.GroupID import com.wire.kalium.logic.data.id.QualifiedIdMapperImpl 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.mls.CipherSuite -import com.wire.kalium.logic.feature.call.scenario.OnCloseCall import com.wire.kalium.logic.framework.TestUser import io.mockative.Mock import io.mockative.any @@ -52,7 +51,7 @@ class OnCloseCallTest { val callRepository = mock(classOf()) @Mock - val mlsCallHelper = mock(classOf()) + val callHelper = mock(classOf()) val qualifiedIdMapper = QualifiedIdMapperImpl(TestUser.SELF.id) @@ -66,7 +65,7 @@ class OnCloseCallTest { fun setUp() { onCloseCall = OnCloseCall( callRepository, - mlsCallHelper, + callHelper, testScope, qualifiedIdMapper ) @@ -282,8 +281,8 @@ class OnCloseCallTest { .with(eq(conversationId), eq(CallStatus.CLOSED)) .wasInvoked(once) - verify(mlsCallHelper) - .suspendFunction(mlsCallHelper::handleCallTermination) + verify(callHelper) + .suspendFunction(callHelper::handleCallTermination) .with(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 43ba41eaf78..fb405fc9ade 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.Participant import com.wire.kalium.logic.data.call.mapper.ParticipantMapper import com.wire.kalium.logic.data.conversation.Conversation @@ -152,7 +152,7 @@ class OnParticipantListChangedTest { val userRepository = mock(UserRepository::class) @Mock - val mlsCallHelper = mock(MLSCallHelper::class) + val callHelper = mock(CallHelper::class) var isEndCallInvoked = false @@ -163,7 +163,7 @@ class OnParticipantListChangedTest { participantMapper = participantMapper, userConfigRepository = userConfigRepository, userRepository = userRepository, - mlsCallHelper = mlsCallHelper, + callHelper = callHelper, qualifiedIdMapper = qualifiedIdMapper, endCall = { isEndCallInvoked = true @@ -200,8 +200,8 @@ class OnParticipantListChangedTest { } fun withShouldEndSFTOneOnOneCall(result: Boolean) = apply { - given(mlsCallHelper) - .function(mlsCallHelper::shouldEndSFTOneOnOneCall) + given(callHelper) + .function(callHelper::shouldEndSFTOneOnOneCall) .whenInvokedWith(any(), any(), any(), any(), any()) .thenReturn(result) }