From cd475926c2237a2521d7931bb997e218585c753b Mon Sep 17 00:00:00 2001 From: Jakub Zerko Date: Fri, 13 Sep 2024 12:23:23 +0200 Subject: [PATCH 1/5] chore: observe only current call --- .../com/wire/kalium/logic/data/call/Call.kt | 3 +- .../logic/data/call/CallMetadataProfile.kt | 2 + gradle/libs.versions.toml | 2 +- .../logic/feature/call/CallManagerImpl.kt | 2 +- .../feature/call/scenario/OnIncomingCall.kt | 2 +- .../kalium/logic/data/call/CallRepository.kt | 34 ++++++++++--- .../logic/data/call/mapper/CallMapper.kt | 2 +- .../kalium/logic/feature/call/CallsScope.kt | 8 +++ ...lishedCallWithSortedParticipantsUseCase.kt | 51 +++++++++++++++++++ .../logic/data/call/CallRepositoryTest.kt | 23 +++++---- .../call/usecase/AnswerCallUseCaseTest.kt | 3 +- .../EndCallOnConversationChangeUseCaseTest.kt | 2 +- .../call/usecase/EndCallUseCaseTest.kt | 3 +- ...lCallsWithSortedParticipantsUseCaseTest.kt | 33 ++++++------ .../call/usecase/IsCallRunningUseCaseTest.kt | 33 ++++++------ .../call/usecase/MuteCallUseCaseTest.kt | 3 +- .../usecase/ObserveOngoingCallsUseCaseTest.kt | 3 +- .../usecase/ObserveOutgoingCallUseCaseTest.kt | 3 +- .../call/usecase/UnMuteCallUseCaseTest.kt | 3 +- ...rsationClientsForCurrentCallUseCaseTest.kt | 3 +- .../video/UpdateVideoStateUseCaseTest.kt | 3 +- .../wire/kalium/logic/framework/TestCall.kt | 9 ++-- .../repository/CallRepositoryArrangement.kt | 3 +- .../feature/call/scenario/OnCloseCallTest.kt | 2 + .../OnMuteStateForSelfUserChangedTest.kt | 3 +- .../scenario/OnParticipantListChangedTest.kt | 5 +- 26 files changed, 171 insertions(+), 72 deletions(-) create mode 100644 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveEstablishedCallWithSortedParticipantsUseCase.kt diff --git a/data/src/commonMain/kotlin/com/wire/kalium/logic/data/call/Call.kt b/data/src/commonMain/kotlin/com/wire/kalium/logic/data/call/Call.kt index fb0adcd8b76..5bc04b0eee8 100644 --- a/data/src/commonMain/kotlin/com/wire/kalium/logic/data/call/Call.kt +++ b/data/src/commonMain/kotlin/com/wire/kalium/logic/data/call/Call.kt @@ -20,6 +20,7 @@ package com.wire.kalium.logic.data.call import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId +import com.wire.kalium.logic.data.id.QualifiedID enum class CallStatus { STARTED, @@ -39,7 +40,7 @@ data class Call( val isMuted: Boolean, val isCameraOn: Boolean, val isCbrEnabled: Boolean, - val callerId: String, + val callerId: QualifiedID, val conversationName: String?, val conversationType: Conversation.Type, val callerName: String?, diff --git a/data/src/commonMain/kotlin/com/wire/kalium/logic/data/call/CallMetadataProfile.kt b/data/src/commonMain/kotlin/com/wire/kalium/logic/data/call/CallMetadataProfile.kt index f3c5ad2b90c..c8c18073978 100644 --- a/data/src/commonMain/kotlin/com/wire/kalium/logic/data/call/CallMetadataProfile.kt +++ b/data/src/commonMain/kotlin/com/wire/kalium/logic/data/call/CallMetadataProfile.kt @@ -20,6 +20,7 @@ package com.wire.kalium.logic.data.call import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId +import com.wire.kalium.logic.data.id.QualifiedID import com.wire.kalium.logic.data.user.OtherUserMinimized import com.wire.kalium.logic.data.user.UserId import com.wire.kalium.logic.data.user.type.UserType @@ -31,6 +32,7 @@ data class CallMetadataProfile( } data class CallMetadata( + val callerId: QualifiedID, val isMuted: Boolean, val isCameraOn: Boolean, val isCbrEnabled: Boolean, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2cf097d9cd3..137d591e3be 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ app-compat = "1.6.1" android-paging3 = "3.2.1" cli-kt = "3.5.0" coroutines = "1.8.0" -compose-compiler = "1.5.11" +compose-compiler = "1.5.14" compose-ui = "1.6.6" compose-material = "1.6.6" cryptobox4j = "1.4.0" 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..64ed19d2c95 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 @@ -305,7 +305,7 @@ class CallManagerImpl internal constructor( isMuted = false, isCameraOn = isCameraOn, isCbrEnabled = isAudioCbr, - callerId = userId.await().toString() + callerId = userId.await() ) withCalling { diff --git a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/scenario/OnIncomingCall.kt b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/scenario/OnIncomingCall.kt index 4c23e8fe868..25b68968352 100644 --- a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/scenario/OnIncomingCall.kt +++ b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/feature/call/scenario/OnIncomingCall.kt @@ -62,7 +62,7 @@ class OnIncomingCall( callRepository.createCall( conversationId = qualifiedConversationId, status = status, - callerId = qualifiedIdMapper.fromStringToQualifiedID(userId).toString(), + callerId = qualifiedIdMapper.fromStringToQualifiedID(userId), isMuted = isMuted, isCameraOn = false, type = mappedConversationType, diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/CallRepository.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/CallRepository.kt index 7c4263a6bcd..e5f8bc07ec4 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/CallRepository.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/CallRepository.kt @@ -81,6 +81,7 @@ import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flattenConcat import kotlinx.coroutines.flow.flowOf +import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.launch import kotlinx.datetime.Clock @@ -108,7 +109,7 @@ interface CallRepository { conversationId: ConversationId, type: ConversationTypeForCall, status: CallStatus, - callerId: String, + callerId: UserId, isMuted: Boolean, isCameraOn: Boolean, isCbrEnabled: Boolean @@ -133,6 +134,7 @@ interface CallRepository { suspend fun observeEpochInfo(conversationId: ConversationId): Either> suspend fun advanceEpoch(conversationId: ConversationId) fun currentCallProtocol(conversationId: ConversationId): Conversation.ProtocolInfo? + suspend fun observeCurrentCall(conversationId: ConversationId): Flow } @Suppress("LongParameterList", "TooManyFunctions") @@ -162,6 +164,26 @@ internal class CallDataSource( private val callJobs = ConcurrentMutableMap() private val staleParticipantJobs = ConcurrentMutableMap() + override suspend fun observeCurrentCall(conversationId: ConversationId): Flow = _callMetadataProfile.map { + it[conversationId]?.let { currentCall -> + Call( + conversationId = conversationId, + status = currentCall.callStatus, + isMuted = currentCall.isMuted, + isCameraOn = currentCall.isCameraOn, + isCbrEnabled = currentCall.isCbrEnabled, + callerId = currentCall.callerId, + conversationName = currentCall.conversationName, + conversationType = currentCall.conversationType, + callerName = currentCall.callerName, + callerTeamName = currentCall.callerTeamName, + establishedTime = currentCall.establishedTime, + participants = currentCall.getFullParticipants(), + maxParticipants = currentCall.maxParticipants + ) + } + } + override suspend fun getCallConfigResponse(limit: Int?): Either = wrapApiRequest { callApi.getCallConfig(limit = limit) } @@ -191,7 +213,7 @@ internal class CallDataSource( conversationId: ConversationId, type: ConversationTypeForCall, status: CallStatus, - callerId: String, + callerId: UserId, isMuted: Boolean, isCameraOn: Boolean, isCbrEnabled: Boolean @@ -199,10 +221,7 @@ internal class CallDataSource( val conversation: ConversationDetails = conversationRepository.observeConversationDetailsById(conversationId).onlyRight().first() - // in OnIncomingCall we get callerId without a domain, - // to cover that case and have a valid UserId we have that workaround - val callerIdWithDomain = qualifiedIdMapper.fromStringToQualifiedID(callerId) - val caller = userRepository.getKnownUser(callerIdWithDomain).first() + val caller = userRepository.getKnownUser(callerId).first() val team = caller?.teamId?.let { teamId -> teamRepository.getTeam(teamId).first() } val callEntity = callMapper.toCallEntity( @@ -211,10 +230,11 @@ internal class CallDataSource( type = type, status = status, conversationType = conversation.conversation.type, - callerId = callerIdWithDomain + callerId = callerId ) val metadata = CallMetadata( + callerId = callerId, conversationName = conversation.conversation.name, conversationType = conversation.conversation.type, callerName = caller?.name, diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/mapper/CallMapper.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/mapper/CallMapper.kt index 19f18747811..caba61b1818 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/mapper/CallMapper.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/call/mapper/CallMapper.kt @@ -180,7 +180,7 @@ class CallMapperImpl( isMuted = metadata?.isMuted ?: true, isCameraOn = metadata?.isCameraOn ?: false, isCbrEnabled = metadata?.isCbrEnabled ?: false, - callerId = callEntity.callerId, + callerId = metadata?.callerId ?: qualifiedIdMapper.fromStringToQualifiedID(callEntity.callerId), conversationName = metadata?.conversationName, conversationType = toConversationType(conversationType = callEntity.conversationType), callerName = metadata?.callerName, diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/call/CallsScope.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/call/CallsScope.kt index 178b25f070a..5d401de2afc 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/call/CallsScope.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/call/CallsScope.kt @@ -53,6 +53,8 @@ import com.wire.kalium.logic.feature.call.usecase.MuteCallUseCaseImpl import com.wire.kalium.logic.feature.call.usecase.ObserveAskCallFeedbackUseCase import com.wire.kalium.logic.feature.call.usecase.ObserveEndCallDueToConversationDegradationUseCase import com.wire.kalium.logic.feature.call.usecase.ObserveEndCallDueToConversationDegradationUseCaseImpl +import com.wire.kalium.logic.feature.call.usecase.ObserveEstablishedCallWithSortedParticipantsUseCase +import com.wire.kalium.logic.feature.call.usecase.ObserveEstablishedCallWithSortedParticipantsUseCaseImpl import com.wire.kalium.logic.feature.call.usecase.ObserveEstablishedCallsUseCase import com.wire.kalium.logic.feature.call.usecase.ObserveEstablishedCallsUseCaseImpl import com.wire.kalium.logic.feature.call.usecase.ObserveOngoingCallsUseCase @@ -129,6 +131,12 @@ class CallsScope internal constructor( callRepository = callRepository, ) + val observeEstablishedCallWithSortedParticipants: ObserveEstablishedCallWithSortedParticipantsUseCase + get() = ObserveEstablishedCallWithSortedParticipantsUseCaseImpl( + callRepository = callRepository, + callingParticipantsOrder = callingParticipantsOrder + ) + val startCall: StartCallUseCase get() = StartCallUseCase( callManager = callManager, diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveEstablishedCallWithSortedParticipantsUseCase.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveEstablishedCallWithSortedParticipantsUseCase.kt new file mode 100644 index 00000000000..f92ee5393f7 --- /dev/null +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveEstablishedCallWithSortedParticipantsUseCase.kt @@ -0,0 +1,51 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.logic.feature.call.usecase + +import com.wire.kalium.logic.data.call.Call +import com.wire.kalium.logic.data.call.CallRepository +import com.wire.kalium.logic.data.call.CallingParticipantsOrder +import com.wire.kalium.logic.data.id.ConversationId +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.map + +/** + * Use case to observe established call with the participants sorted according to the [CallingParticipantsOrder] + */ +interface ObserveEstablishedCallWithSortedParticipantsUseCase { + suspend operator fun invoke(conversationId: ConversationId): Flow +} + +class ObserveEstablishedCallWithSortedParticipantsUseCaseImpl internal constructor( + private val callRepository: CallRepository, + private val callingParticipantsOrder: CallingParticipantsOrder +) : ObserveEstablishedCallWithSortedParticipantsUseCase { + + override suspend operator fun invoke(conversationId: ConversationId): Flow { + return callRepository.observeCurrentCall(conversationId) + .distinctUntilChanged() + .map { call -> + call?.let { + val sortedParticipants = callingParticipantsOrder.reorderItems(call.participants) + call.copy(participants = sortedParticipants) + } + } + } +} diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/CallRepositoryTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/CallRepositoryTest.kt index 18cc5052316..8ac2fed6636 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/CallRepositoryTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/call/CallRepositoryTest.kt @@ -192,7 +192,7 @@ class CallRepositoryTest { callRepository.createCall( conversationId = Arrangement.conversationId, status = CallStatus.STARTED, - callerId = callerId.value, + callerId = callerId, isMuted = true, isCameraOn = false, isCbrEnabled = false, @@ -242,7 +242,7 @@ class CallRepositoryTest { callRepository.createCall( conversationId = Arrangement.conversationId, status = CallStatus.STARTED, - callerId = callerId.value, + callerId = callerId, isMuted = true, isCameraOn = false, isCbrEnabled = false, @@ -288,7 +288,7 @@ class CallRepositoryTest { callRepository.createCall( conversationId = Arrangement.conversationId, status = CallStatus.INCOMING, - callerId = callerId.value, + callerId = callerId, isMuted = true, isCameraOn = false, isCbrEnabled = false, @@ -343,7 +343,7 @@ class CallRepositoryTest { callRepository.createCall( conversationId = Arrangement.conversationId, status = CallStatus.INCOMING, - callerId = callerId.value, + callerId = callerId, isMuted = true, isCameraOn = false, isCbrEnabled = false, @@ -392,7 +392,7 @@ class CallRepositoryTest { callRepository.createCall( conversationId = Arrangement.conversationId, status = CallStatus.INCOMING, - callerId = callerId.value, + callerId = callerId, isMuted = true, isCameraOn = false, isCbrEnabled = false, @@ -427,7 +427,7 @@ class CallRepositoryTest { callRepository.createCall( conversationId = Arrangement.conversationId, status = CallStatus.STARTED, - callerId = callerId.value, + callerId = callerId, isMuted = true, isCameraOn = false, isCbrEnabled = false, @@ -466,7 +466,7 @@ class CallRepositoryTest { callRepository.createCall( conversationId = Arrangement.conversationId, status = CallStatus.STARTED, - callerId = callerId.value, + callerId = callerId, isMuted = true, isCameraOn = false, isCbrEnabled = false, @@ -504,7 +504,7 @@ class CallRepositoryTest { callRepository.createCall( conversationId = Arrangement.conversationId, status = CallStatus.INCOMING, - callerId = callerId.value, + callerId = callerId, isMuted = true, isCameraOn = false, isCbrEnabled = false, @@ -550,7 +550,7 @@ class CallRepositoryTest { callRepository.createCall( conversationId = Arrangement.conversationId, status = CallStatus.INCOMING, - callerId = callerId.value, + callerId = callerId, isMuted = true, isCameraOn = false, isCbrEnabled = false, @@ -587,7 +587,7 @@ class CallRepositoryTest { callRepository.createCall( conversationId = Arrangement.conversationId, status = CallStatus.INCOMING, - callerId = callerId.value, + callerId = callerId, isMuted = true, isCameraOn = false, isCbrEnabled = false, @@ -1477,7 +1477,7 @@ class CallRepositoryTest { private fun provideCall(id: ConversationId, status: CallStatus) = Call( conversationId = id, status = status, - callerId = "callerId@domain", + callerId = UserId("callerId", "domain"), participants = listOf(), isMuted = false, isCameraOn = false, @@ -1502,6 +1502,7 @@ class CallRepositoryTest { ) private fun createCallMetadata() = CallMetadata( + callerId = callerId, isMuted = true, isCameraOn = false, isCbrEnabled = false, diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/AnswerCallUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/AnswerCallUseCaseTest.kt index 9dfc156e3d6..38da64e9139 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/AnswerCallUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/AnswerCallUseCaseTest.kt @@ -24,6 +24,7 @@ import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.feature.call.CallManager import com.wire.kalium.logic.featureFlags.KaliumConfigs +import com.wire.kalium.logic.framework.TestCall import com.wire.kalium.logic.test_util.TestKaliumDispatcher import com.wire.kalium.logic.test_util.testKaliumDispatcher import io.mockative.Mock @@ -170,7 +171,7 @@ class AnswerCallUseCaseTest { isMuted = true, isCameraOn = false, isCbrEnabled = false, - callerId = "id", + callerId = TestCall.CALLER_ID, conversationName = "caller-name", conversationType = Conversation.Type.GROUP, callerName = "Name", diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/EndCallOnConversationChangeUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/EndCallOnConversationChangeUseCaseTest.kt index d858391e5b2..45c45fabca6 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/EndCallOnConversationChangeUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/EndCallOnConversationChangeUseCaseTest.kt @@ -190,7 +190,7 @@ class EndCallOnConversationChangeUseCaseTest { private val call = Call( conversationId = conversationId, status = CallStatus.ESTABLISHED, - callerId = "called-id", + callerId = UserId("called-id", "domain"), isMuted = false, isCameraOn = false, isCbrEnabled = false, diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/EndCallUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/EndCallUseCaseTest.kt index 5e0c182068e..76cd6521604 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/EndCallUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/EndCallUseCaseTest.kt @@ -22,6 +22,7 @@ import com.wire.kalium.logic.data.call.Call import com.wire.kalium.logic.data.call.CallStatus import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId +import com.wire.kalium.logic.data.user.UserId import com.wire.kalium.logic.feature.user.ShouldAskCallFeedbackUseCase import com.wire.kalium.logic.test_util.TestKaliumDispatcher import com.wire.kalium.logic.util.arrangement.repository.CallManagerArrangement @@ -233,7 +234,7 @@ class EndCallUseCaseTest { private val call = Call( conversationId = conversationId, status = CallStatus.ESTABLISHED, - callerId = "called-id", + callerId = UserId("called-id", "domain"), isMuted = false, isCameraOn = false, isCbrEnabled = false, diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/GetAllCallsWithSortedParticipantsUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/GetAllCallsWithSortedParticipantsUseCaseTest.kt index 0756e2e9a07..e1827ca17b1 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/GetAllCallsWithSortedParticipantsUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/GetAllCallsWithSortedParticipantsUseCaseTest.kt @@ -25,6 +25,7 @@ import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.data.call.Call import com.wire.kalium.logic.data.call.CallStatus +import com.wire.kalium.logic.data.user.UserId import io.mockative.Mock import io.mockative.coEvery import io.mockative.mock @@ -85,26 +86,26 @@ class GetAllCallsWithSortedParticipantsUseCaseTest { private val call1 = Call( ConversationId("first", "domain"), CallStatus.STARTED, - true, - false, - false, - "caller-id", - "ONE_ON_ONE Name", - Conversation.Type.ONE_ON_ONE, - "otherUsername", - "team1" + isMuted = true, + isCameraOn = false, + isCbrEnabled = false, + callerId = UserId("called-id", "domain"), + conversationName = "ONE_ON_ONE Name", + conversationType = Conversation.Type.ONE_ON_ONE, + callerName = "otherUsername", + callerTeamName = "team1" ) private val call2 = Call( ConversationId("second", "domain"), CallStatus.INCOMING, - true, - false, - false, - "caller-id", - "ONE_ON_ONE Name", - Conversation.Type.ONE_ON_ONE, - "otherUsername2", - "team2" + isMuted = true, + isCameraOn = false, + isCbrEnabled = false, + callerId = UserId("called-id", "domain"), + conversationName = "ONE_ON_ONE Name", + conversationType = Conversation.Type.ONE_ON_ONE, + callerName = "otherUsername2", + callerTeamName = "team2" ) } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/IsCallRunningUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/IsCallRunningUseCaseTest.kt index cfe36df3813..afd799b4e38 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/IsCallRunningUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/IsCallRunningUseCaseTest.kt @@ -23,6 +23,7 @@ import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.data.call.Call import com.wire.kalium.logic.data.call.CallStatus +import com.wire.kalium.logic.data.user.UserId import io.mockative.Mock import io.mockative.coEvery import io.mockative.mock @@ -83,26 +84,26 @@ class IsCallRunningUseCaseTest { private val call1 = Call( ConversationId("first", "domain"), CallStatus.STARTED, - true, - false, - false, - "caller-id1", - "ONE_ON_ONE Name", - Conversation.Type.ONE_ON_ONE, - "otherUsername", - "team1" + isMuted = true, + isCameraOn = false, + isCbrEnabled = false, + callerId = UserId("caller-id1", "domain"), + conversationName = "ONE_ON_ONE Name", + conversationType = Conversation.Type.ONE_ON_ONE, + callerName = "otherUsername", + callerTeamName = "team1" ) private val call2 = Call( ConversationId("second", "domain"), CallStatus.CLOSED, - true, - false, - false, - "caller-id2", - "ONE_ON_ONE Name", - Conversation.Type.ONE_ON_ONE, - "otherUsername", - "team1" + isMuted = true, + isCameraOn = false, + isCbrEnabled = false, + callerId = UserId("caller-id2", "domain"), + conversationName = "ONE_ON_ONE Name", + conversationType = Conversation.Type.ONE_ON_ONE, + callerName = "otherUsername", + callerTeamName = "team1" ) } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/MuteCallUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/MuteCallUseCaseTest.kt index 41f6a3bb0a3..df0bbacc84c 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/MuteCallUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/MuteCallUseCaseTest.kt @@ -24,6 +24,7 @@ import com.wire.kalium.logic.data.call.CallStatus import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.feature.call.CallManager +import com.wire.kalium.logic.framework.TestCall import io.mockative.Mock import io.mockative.coEvery import io.mockative.coVerify @@ -100,7 +101,7 @@ class MuteCallUseCaseTest { val call = Call( conversationId = conversationId, status = CallStatus.ESTABLISHED, - callerId = "called-id", + callerId = TestCall.CALLER_ID, isMuted = false, isCameraOn = false, isCbrEnabled = false, diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveOngoingCallsUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveOngoingCallsUseCaseTest.kt index 7f573fba700..0dfd7fca4f0 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveOngoingCallsUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveOngoingCallsUseCaseTest.kt @@ -24,6 +24,7 @@ import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.data.call.Call import com.wire.kalium.logic.data.call.CallStatus +import com.wire.kalium.logic.framework.TestCall import io.mockative.Mock import io.mockative.coEvery import io.mockative.mock @@ -85,7 +86,7 @@ class ObserveOngoingCallsUseCaseTest { isMuted = false, isCameraOn = false, isCbrEnabled = false, - callerId = "callerId", + callerId = TestCall.CALLER_ID, conversationName = null, conversationType = Conversation.Type.GROUP, callerName = null, diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveOutgoingCallUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveOutgoingCallUseCaseTest.kt index 539e9e2a95a..ff89652a0b4 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveOutgoingCallUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveOutgoingCallUseCaseTest.kt @@ -22,6 +22,7 @@ import com.wire.kalium.logic.data.call.CallRepository import com.wire.kalium.logic.data.call.CallStatus import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId +import com.wire.kalium.logic.framework.TestCall import io.mockative.Mock import io.mockative.coEvery import io.mockative.mock @@ -68,7 +69,7 @@ class ObserveOutgoingCallUseCaseTest { domain = "conversationDomain" ), status = CallStatus.STARTED, - callerId = "callerId@domain", + callerId = TestCall.CALLER_ID, participants = listOf(), isMuted = true, isCameraOn = false, diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/UnMuteCallUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/UnMuteCallUseCaseTest.kt index cd692cefe66..a5251f2be2f 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/UnMuteCallUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/UnMuteCallUseCaseTest.kt @@ -24,6 +24,7 @@ import com.wire.kalium.logic.data.call.CallStatus import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.feature.call.CallManager +import com.wire.kalium.logic.framework.TestCall import io.mockative.Mock import io.mockative.coEvery import io.mockative.coVerify @@ -96,7 +97,7 @@ class UnMuteCallUseCaseTest { val call = Call( conversationId = conversationId, status = CallStatus.ESTABLISHED, - callerId = "called-id", + callerId = TestCall.CALLER_ID, isMuted = false, isCameraOn = false, isCbrEnabled = false, diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/UpdateConversationClientsForCurrentCallUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/UpdateConversationClientsForCurrentCallUseCaseTest.kt index d5ca67a41e3..226c77120ec 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/UpdateConversationClientsForCurrentCallUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/UpdateConversationClientsForCurrentCallUseCaseTest.kt @@ -22,6 +22,7 @@ import com.wire.kalium.logic.data.call.CallRepository import com.wire.kalium.logic.data.call.CallStatus import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId +import com.wire.kalium.logic.framework.TestCall import io.mockative.Mock import io.mockative.coEvery import io.mockative.coVerify @@ -89,7 +90,7 @@ class UpdateConversationClientsForCurrentCallUseCaseTest { private val call = Call( conversationId = CONVERSATION_ID, status = CallStatus.ESTABLISHED, - callerId = "called-id", + callerId = TestCall.CALLER_ID, isMuted = false, isCameraOn = false, isCbrEnabled = false, diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/video/UpdateVideoStateUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/video/UpdateVideoStateUseCaseTest.kt index 2c203d7c738..337c15cf87b 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/video/UpdateVideoStateUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/call/usecase/video/UpdateVideoStateUseCaseTest.kt @@ -24,6 +24,7 @@ import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.data.call.Call import com.wire.kalium.logic.data.call.CallStatus +import com.wire.kalium.logic.framework.TestCall import io.mockative.Mock import io.mockative.eq import io.mockative.coEvery @@ -59,7 +60,7 @@ class UpdateVideoStateUseCaseTest { isMuted = true, isCameraOn = true, isCbrEnabled = false, - callerId = "caller-id", + callerId = TestCall.CALLER_ID, conversationName = "", Conversation.Type.ONE_ON_ONE, null, diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/framework/TestCall.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/framework/TestCall.kt index 52bfb67437f..7904879e12f 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/framework/TestCall.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/framework/TestCall.kt @@ -91,6 +91,7 @@ object TestCall { ) ), activeSpeakers = mapOf(QualifiedID("participantId", "participantDomain") to listOf("abcd")), + callerId = CALLER_ID, users = listOf( OtherUserMinimized( id = QualifiedID("participantId", "participantDomain"), @@ -108,7 +109,7 @@ object TestCall { isMuted = true, isCameraOn = false, isCbrEnabled = false, - callerId = CALLER_ID.toString(), + callerId = CALLER_ID, conversationName = CONVERSATION_NAME, conversationType = Conversation.Type.ONE_ON_ONE, callerName = CALLER_NAME, @@ -139,11 +140,11 @@ object TestCall { false, false, false, - "client1", + UserId("client1", "domain"), "ONE_ON_ONE Name ${convId.value}", Conversation.Type.ONE_ON_ONE, null, - null + null, ) fun groupIncomingCall(convId: ConversationId) = @@ -153,7 +154,7 @@ object TestCall { false, false, false, - "client1", + UserId("client1", "domain"), "ONE_ON_ONE Name ${convId.value}", Conversation.Type.GROUP, null, diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/CallRepositoryArrangement.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/CallRepositoryArrangement.kt index e275e2a851c..5827fdd6153 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/CallRepositoryArrangement.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/CallRepositoryArrangement.kt @@ -23,6 +23,7 @@ import com.wire.kalium.logic.data.call.CallStatus import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.data.user.UserId +import com.wire.kalium.logic.framework.TestCall import io.mockative.Mock import io.mockative.any import io.mockative.coEvery @@ -77,7 +78,7 @@ internal open class CallRepositoryArrangementImpl : CallRepositoryArrangement { val call = Call( conversationId = ConversationId("conversationId", "domain"), status = CallStatus.ESTABLISHED, - callerId = UserId("caller", "domain").toString(), + callerId = TestCall.CALLER_ID, participants = listOf(), isMuted = true, isCameraOn = false, 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..530a9320530 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 @@ -29,6 +29,7 @@ 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.mls.CipherSuite +import com.wire.kalium.logic.framework.TestCall import com.wire.kalium.logic.framework.TestUser import com.wire.kalium.network.NetworkState import com.wire.kalium.network.NetworkStateObserver @@ -351,6 +352,7 @@ class OnCloseCallTest { private const val clientId = "clientId" private val callMetadata = CallMetadata( + callerId = TestCall.CALLER_ID, isMuted = false, isCameraOn = false, isCbrEnabled = false, diff --git a/logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnMuteStateForSelfUserChangedTest.kt b/logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnMuteStateForSelfUserChangedTest.kt index fd5d87984f8..98f4c92b9fb 100644 --- a/logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnMuteStateForSelfUserChangedTest.kt +++ b/logic/src/jvmTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnMuteStateForSelfUserChangedTest.kt @@ -23,6 +23,7 @@ import com.wire.kalium.logic.data.call.CallStatus import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.feature.call.scenario.OnMuteStateForSelfUserChanged +import com.wire.kalium.logic.framework.TestCall import com.wire.kalium.logic.test_util.TestKaliumDispatcher import io.mockative.Mock import io.mockative.any @@ -98,7 +99,7 @@ class OnMuteStateForSelfUserChangedTest { private val call = Call( conversationId = conversationId, status = CallStatus.ESTABLISHED, - callerId = "called-id", + callerId = TestCall.CALLER_ID, isMuted = false, isCameraOn = false, isCbrEnabled = false, 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..9fa1d838aef 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 @@ -31,6 +31,7 @@ import com.wire.kalium.logic.data.id.GroupID import com.wire.kalium.logic.data.id.QualifiedID import com.wire.kalium.logic.data.id.QualifiedIdMapperImpl import com.wire.kalium.logic.data.mls.CipherSuite +import com.wire.kalium.logic.data.user.UserId import com.wire.kalium.logic.framework.TestUser import com.wire.kalium.logic.functional.Either import io.mockative.Mock @@ -231,7 +232,7 @@ class OnParticipantListChangedTest { private val call = Call( conversationId = conversationId, status = CallStatus.ESTABLISHED, - callerId = "called-id", + callerId = UserId("called-id", "domain"), isMuted = false, isCameraOn = false, isCbrEnabled = false, @@ -242,4 +243,4 @@ class OnParticipantListChangedTest { establishedTime = null ) } -} \ No newline at end of file +} From d257c2a040f51e511fc8e085efab95ce9002e992 Mon Sep 17 00:00:00 2001 From: Jakub Zerko Date: Fri, 13 Sep 2024 14:26:01 +0200 Subject: [PATCH 2/5] kotlin update --- gradle/libs.versions.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 137d591e3be..f6b0a4d292d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,6 @@ [versions] -kotlin = "1.9.23" +kotlin = "1.9.24" +ksp = "1.9.24-1.0.20" activity-compose = "1.9.0" app-compat = "1.6.1" android-paging3 = "3.2.1" @@ -78,7 +79,7 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } -ksp = { id = "com.google.devtools.ksp", version = "1.9.23-1.0.20" } +ksp = { id = "com.google.devtools.ksp", versio.ref = "ksp" } carthage = { id = "com.wire.carthage-gradle-plugin", version.ref = "carthage" } sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" } protobuf = { id = "com.google.protobuf", version.ref = "protobufCodegen" } From c2c4f788ac83146bcfed10882865f07b435da7d2 Mon Sep 17 00:00:00 2001 From: Jakub Zerko Date: Fri, 13 Sep 2024 16:21:54 +0200 Subject: [PATCH 3/5] downgrade compose compiler and kotlin --- gradle/libs.versions.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ee343a0b505..f9d119c6609 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,12 +1,12 @@ [versions] -kotlin = "1.9.24" -ksp = "1.9.24-1.0.20" +kotlin = "1.9.23" +ksp = "1.9.23-1.0.20" activity-compose = "1.9.0" app-compat = "1.6.1" android-paging3 = "3.2.1" cli-kt = "3.5.0" coroutines = "1.8.0" -compose-compiler = "1.5.14" +compose-compiler = "1.5.13" compose-ui = "1.6.6" compose-material = "1.6.6" cryptobox4j = "1.4.0" From 55497291f079edbe9883fbf63902307c6d64b078 Mon Sep 17 00:00:00 2001 From: Jakub Zerko Date: Fri, 13 Sep 2024 16:26:19 +0200 Subject: [PATCH 4/5] version typo --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f9d119c6609..1bdfe0588cb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -80,7 +80,7 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } -ksp = { id = "com.google.devtools.ksp", versio.ref = "ksp" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } carthage = { id = "com.wire.carthage-gradle-plugin", version.ref = "carthage" } sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" } protobuf = { id = "com.google.protobuf", version.ref = "protobufCodegen" } From 0052aab09668ea7a30e699dbf9c44c647a178813 Mon Sep 17 00:00:00 2001 From: Jakub Zerko Date: Fri, 13 Sep 2024 17:04:49 +0200 Subject: [PATCH 5/5] tests fix --- .../logic/feature/call/scenario/OnIncomingCallTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/logic/src/androidInstrumentedTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnIncomingCallTest.kt b/logic/src/androidInstrumentedTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnIncomingCallTest.kt index 89525e689a3..1bb4efa23d1 100644 --- a/logic/src/androidInstrumentedTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnIncomingCallTest.kt +++ b/logic/src/androidInstrumentedTest/kotlin/com/wire/kalium/logic/feature/call/scenario/OnIncomingCallTest.kt @@ -17,13 +17,13 @@ */ package com.wire.kalium.logic.feature.call.scenario -import com.wire.kalium.calling.types.Uint32_t import com.wire.kalium.calling.ConversationTypeCalling +import com.wire.kalium.calling.types.Uint32_t import com.wire.kalium.logic.data.call.CallRepository +import com.wire.kalium.logic.data.call.CallStatus import com.wire.kalium.logic.data.call.ConversationTypeForCall import com.wire.kalium.logic.data.call.mapper.CallMapperImpl import com.wire.kalium.logic.data.id.QualifiedIdMapperImpl -import com.wire.kalium.logic.data.call.CallStatus import com.wire.kalium.logic.featureFlags.KaliumConfigs import com.wire.kalium.logic.framework.TestClient import com.wire.kalium.logic.framework.TestConversation @@ -66,7 +66,7 @@ class OnIncomingCallTest { eq(TestConversation.CONVERSATION.id), eq(ConversationTypeForCall.Conference), eq(CallStatus.INCOMING), - eq(TestUser.USER_ID.toString()), + eq(TestUser.USER_ID), eq(true), eq(false), eq(false) @@ -96,7 +96,7 @@ class OnIncomingCallTest { eq(TestConversation.CONVERSATION.id), eq(ConversationTypeForCall.Conference), eq(CallStatus.STILL_ONGOING), - eq(TestUser.USER_ID.toString()), + eq(TestUser.USER_ID), eq(true), eq(false), eq(false)