Skip to content

Commit

Permalink
chore: Remove call to deleteSubConversation after ending 1:1 call (WP…
Browse files Browse the repository at this point in the history
…B-11007) 🍒 (#3015)

* Commit with unresolved merge conflicts

* fix: resolve conflicts

---------

Co-authored-by: Oussama Hassine <[email protected]>
  • Loading branch information
github-actions[bot] and ohassine authored Sep 23, 2024
1 parent 3e6a84f commit c38fab7
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.wire.kalium.logic.data.call.VideoStateChecker
import com.wire.kalium.logic.data.call.mapper.CallMapperImpl
import com.wire.kalium.logic.data.conversation.ClientId
import com.wire.kalium.logic.data.conversation.ConversationRepository
import com.wire.kalium.logic.data.conversation.SubconversationRepository
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.id.CurrentClientIdProvider
import com.wire.kalium.logic.data.id.FederatedIdMapper
Expand Down Expand Up @@ -80,9 +79,6 @@ class CallManagerTest {
@Mock
private val selfConversationIdProvider = mock(SelfConversationIdProvider::class)

@Mock
private val subconversationRepository = mock(SubconversationRepository::class)

@Mock
private val userConfigRepository = mock(UserConfigRepository::class)

Expand Down Expand Up @@ -124,7 +120,6 @@ class CallManagerTest {
currentClientIdProvider = currentClientIdProvider,
selfConversationIdProvider = selfConversationIdProvider,
conversationRepository = conversationRepository,
subconversationRepository = subconversationRepository,
userConfigRepository = userConfigRepository,
messageSender = messageSender,
kaliumDispatchers = dispatcher,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import com.wire.kalium.logic.data.call.CallRepository
import com.wire.kalium.logic.data.call.VideoStateChecker
import com.wire.kalium.logic.data.call.mapper.CallMapper
import com.wire.kalium.logic.data.conversation.ConversationRepository
import com.wire.kalium.logic.data.conversation.SubconversationRepository
import com.wire.kalium.logic.data.id.CurrentClientIdProvider
import com.wire.kalium.logic.data.id.FederatedIdMapper
import com.wire.kalium.logic.data.id.QualifiedID
Expand All @@ -48,7 +47,6 @@ actual class GlobalCallManager {
currentClientIdProvider: CurrentClientIdProvider,
selfConversationIdProvider: SelfConversationIdProvider,
conversationRepository: ConversationRepository,
subconversationRepository: SubconversationRepository,
userConfigRepository: UserConfigRepository,
messageSender: MessageSender,
callMapper: CallMapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import com.wire.kalium.logic.data.call.mapper.ParticipantMapperImpl
import com.wire.kalium.logic.data.conversation.ClientId
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.conversation.ConversationRepository
import com.wire.kalium.logic.data.conversation.SubconversationRepository
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.id.CurrentClientIdProvider
import com.wire.kalium.logic.data.id.FederatedIdMapper
Expand Down Expand Up @@ -114,7 +113,6 @@ class CallManagerImpl internal constructor(
private val conversationClientsInCallUpdater: ConversationClientsInCallUpdater,
private val networkStateObserver: NetworkStateObserver,
private val getCallConversationType: GetCallConversationTypeProvider,
private val subconversationRepository: SubconversationRepository,
private val userConfigRepository: UserConfigRepository,
private val kaliumConfigs: KaliumConfigs,
private val mediaManagerService: MediaManagerService,
Expand Down Expand Up @@ -216,7 +214,6 @@ class CallManagerImpl internal constructor(
.keepingStrongReference(),
closeCallHandler = OnCloseCall(
callRepository = callRepository,
callHelper = CallHelperImpl(callRepository, subconversationRepository, userConfigRepository),
networkStateObserver = networkStateObserver,
scope = scope,
qualifiedIdMapper = qualifiedIdMapper
Expand Down Expand Up @@ -543,11 +540,7 @@ class CallManagerImpl internal constructor(
qualifiedIdMapper = qualifiedIdMapper,
participantMapper = ParticipantMapperImpl(videoStateChecker, callMapper, qualifiedIdMapper),
userConfigRepository = userConfigRepository,
callHelper = CallHelperImpl(
callRepository = callRepository,
subconversationRepository = subconversationRepository,
userConfigRepository = userConfigRepository
),
callHelper = CallHelperImpl(),
endCall = { endCall(it) },
callingScope = scope
).keepingStrongReference()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import com.wire.kalium.logic.data.call.CallRepository
import com.wire.kalium.logic.data.call.VideoStateChecker
import com.wire.kalium.logic.data.call.mapper.CallMapper
import com.wire.kalium.logic.data.conversation.ConversationRepository
import com.wire.kalium.logic.data.conversation.SubconversationRepository
import com.wire.kalium.logic.data.id.CurrentClientIdProvider
import com.wire.kalium.logic.data.id.FederatedIdMapper
import com.wire.kalium.logic.data.id.QualifiedID
Expand Down Expand Up @@ -85,7 +84,6 @@ actual class GlobalCallManager(
currentClientIdProvider: CurrentClientIdProvider,
selfConversationIdProvider: SelfConversationIdProvider,
conversationRepository: ConversationRepository,
subconversationRepository: SubconversationRepository,
userConfigRepository: UserConfigRepository,
messageSender: MessageSender,
callMapper: CallMapper,
Expand Down Expand Up @@ -115,7 +113,6 @@ actual class GlobalCallManager(
networkStateObserver = networkStateObserver,
mediaManagerService = mediaManager,
flowManagerService = flowManager,
subconversationRepository = subconversationRepository,
userConfigRepository = userConfigRepository,
kaliumConfigs = kaliumConfigs
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ 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.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
Expand All @@ -40,7 +39,6 @@ import kotlinx.coroutines.launch
@Suppress("LongParameterList")
class OnCloseCall(
private val callRepository: CallRepository,
private val callHelper: CallHelper,
private val scope: CoroutineScope,
private val qualifiedIdMapper: QualifiedIdMapper,
private val networkStateObserver: NetworkStateObserver
Expand All @@ -65,8 +63,13 @@ class OnCloseCall(

scope.launch {

val isConnectedToInternet = networkStateObserver.observeNetworkState().value == NetworkState.ConnectedWithInternet
if (shouldPersistMissedCall(conversationIdWithDomain, callStatus) && isConnectedToInternet) {
val isConnectedToInternet =
networkStateObserver.observeNetworkState().value == NetworkState.ConnectedWithInternet
if (shouldPersistMissedCall(
conversationIdWithDomain,
callStatus
) && isConnectedToInternet
) {
callRepository.persistMissedCall(conversationIdWithDomain)
}

Expand All @@ -75,11 +78,8 @@ class OnCloseCall(
status = callStatus
)

val conversationType =
callRepository.getCallMetadataProfile()[conversationIdWithDomain]?.conversationType

if (callRepository.getCallMetadataProfile()[conversationIdWithDomain]?.protocol is Conversation.ProtocolInfo.MLS) {
callHelper.handleCallTermination(conversationIdWithDomain, conversationType)
callRepository.leaveMlsConference(conversationIdWithDomain)
}
callingLogger.i("[OnCloseCall] -> ConversationId: ${conversationId.obfuscateId()} | callStatus: $callStatus")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,8 @@
*/
package com.wire.kalium.logic.data.call

import com.wire.kalium.logic.callingLogger
import com.wire.kalium.logic.configuration.UserConfigRepository
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.conversation.SubconversationRepository
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.id.SubconversationId
import com.wire.kalium.logic.data.id.toModel
import com.wire.kalium.logic.functional.getOrElse
import com.wire.kalium.logic.functional.onFailure
import com.wire.kalium.logic.functional.onSuccess
import com.wire.kalium.network.api.authenticated.conversation.SubconversationDeleteRequest

/**
* Helper class to handle call related operations.
Expand All @@ -53,27 +44,9 @@ interface CallHelper {
newCallParticipants: List<ParticipantMinimized>,
previousCallParticipants: List<Participant>
): Boolean

/**
* Handle the call termination.
* If the call is oneOneOne on SFT, then delete MLS sub conversation
* otherwise leave the MLS conference.
*
* @param conversationId the conversation id.
* @param callProtocol the call protocol.
* @param conversationType the conversation type.
*/
suspend fun handleCallTermination(
conversationId: ConversationId,
conversationType: Conversation.Type?
)
}

class CallHelperImpl(
private val callRepository: CallRepository,
private val subconversationRepository: SubconversationRepository,
private val userConfigRepository: UserConfigRepository
) : CallHelper {
class CallHelperImpl : CallHelper {

override fun shouldEndSFTOneOnOneCall(
conversationId: ConversationId,
Expand All @@ -94,36 +67,6 @@ class CallHelperImpl(
}
}

override suspend fun handleCallTermination(
conversationId: ConversationId,
conversationType: Conversation.Type?
) {
if (userConfigRepository.shouldUseSFTForOneOnOneCalls().getOrElse(false) &&
conversationType == Conversation.Type.ONE_ON_ONE
) {
callingLogger.i("[CallHelper] -> fetching remote MLS sub conversation details")
subconversationRepository.fetchRemoteSubConversationDetails(
conversationId,
CALL_SUBCONVERSATION_ID
).onSuccess { subconversationDetails ->
callingLogger.i("[CallHelper] -> Deleting remote MLS sub conversation")
subconversationRepository.deleteRemoteSubConversation(
subconversationDetails.parentId.toModel(),
SubconversationId(subconversationDetails.id),
SubconversationDeleteRequest(
subconversationDetails.epoch,
subconversationDetails.groupId
)
)
}.onFailure {
callingLogger.e("[CallHelper] -> Error fetching remote MLS sub conversation details")
}
} else {
callingLogger.i("[CallHelper] -> Leaving MLS conference")
callRepository.leaveMlsConference(conversationId)
}
}

companion object {
const val TWO_PARTICIPANTS = 2
const val ONE_PARTICIPANTS = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,6 @@ class UserSessionScope internal constructor(
userRepository = userRepository,
currentClientIdProvider = clientIdProvider,
conversationRepository = conversationRepository,
subconversationRepository = subconversationRepository,
userConfigRepository = userConfigRepository,
selfConversationIdProvider = selfConversationIdProvider,
messageSender = messages.messageSender,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import com.wire.kalium.logic.data.call.mapper.CallMapper
import com.wire.kalium.logic.data.call.CallRepository
import com.wire.kalium.logic.data.call.VideoStateChecker
import com.wire.kalium.logic.data.conversation.ConversationRepository
import com.wire.kalium.logic.data.conversation.SubconversationRepository
import com.wire.kalium.logic.data.id.FederatedIdMapper
import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.data.id.QualifiedIdMapper
Expand All @@ -49,7 +48,6 @@ expect class GlobalCallManager {
currentClientIdProvider: CurrentClientIdProvider,
selfConversationIdProvider: SelfConversationIdProvider,
conversationRepository: ConversationRepository,
subconversationRepository: SubconversationRepository,
userConfigRepository: UserConfigRepository,
messageSender: MessageSender,
callMapper: CallMapper,
Expand Down
Loading

0 comments on commit c38fab7

Please sign in to comment.