From 5707160292b5daf96042558a41007f34d27ac69d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:53:32 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20add=20useSFTForOneToOneCalls=20flag=20(?= =?UTF-8?q?WPB-7153)=20=F0=9F=8D=92=20(#2892)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add useSFTForOneToOneCalls flag (WPB-7153) (#2889) * feat: add useSFTForOneToOneCalls flag * chore: uni test * chore: unit test * chore: Empty-Commit --------- Co-authored-by: Oussama Hassine --- .../data/featureConfig/FeatureConfigModel.kt | 3 +- .../configuration/UserConfigRepository.kt | 10 ++ .../data/featureConfig/FeatureConfigMapper.kt | 3 +- .../SyncFeatureConfigsUseCase.kt | 2 +- .../handler/ConferenceCallingConfigHandler.kt | 6 +- .../data/event/FeatureConfigMapperTest.kt | 3 +- .../FeatureConfigRepositoryTest.kt | 5 +- .../data/featureConfig/FeatureConfigTest.kt | 2 +- .../SyncFeatureConfigsUseCaseTest.kt | 4 +- .../ConferenceCallingConfigHandlerTest.kt | 141 ++++++++++++++++++ .../FeatureConfigEventReceiverTest.kt | 24 ++- .../mocks/responses/FeatureConfigJson.kt | 6 +- .../responses/FeatureConfigResponseJson.kt | 3 +- .../featureConfigs/FeatureConfigResponse.kt | 10 +- .../persistence/config/UserConfigStorage.kt | 16 ++ 15 files changed, 221 insertions(+), 17 deletions(-) create mode 100644 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/ConferenceCallingConfigHandlerTest.kt diff --git a/data/src/commonMain/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigModel.kt b/data/src/commonMain/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigModel.kt index 17d630a2025..1fa12985a76 100644 --- a/data/src/commonMain/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigModel.kt +++ b/data/src/commonMain/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigModel.kt @@ -90,7 +90,8 @@ data class MLSMigrationModel( ) data class ConferenceCallingModel( - val status: Status + val status: Status, + val useSFTForOneOnOneCalls: Boolean ) data class E2EIModel( diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/configuration/UserConfigRepository.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/configuration/UserConfigRepository.kt index a132c85ebd0..51b0d969358 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/configuration/UserConfigRepository.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/configuration/UserConfigRepository.kt @@ -93,6 +93,8 @@ interface UserConfigRepository { suspend fun getSupportedProtocols(): Either> fun setConferenceCallingEnabled(enabled: Boolean): Either fun isConferenceCallingEnabled(): Either + fun setUseSFTForOneOnOneCalls(shouldUse: Boolean): Either + fun shouldUseSFTForOneOnOneCalls(): Either fun setSecondFactorPasswordChallengeStatus(isRequired: Boolean): Either fun isSecondFactorPasswordChallengeRequired(): Either fun isReadReceiptsEnabled(): Flow> @@ -298,6 +300,14 @@ internal class UserConfigDataSource internal constructor( userConfigStorage.isConferenceCallingEnabled() } + override fun setUseSFTForOneOnOneCalls(shouldUse: Boolean): Either = wrapStorageRequest { + userConfigStorage.persistUseSftForOneOnOneCalls(shouldUse) + } + + override fun shouldUseSFTForOneOnOneCalls(): Either = wrapStorageRequest { + userConfigStorage.shouldUseSftForOneOnOneCalls() + } + override fun setSecondFactorPasswordChallengeStatus(isRequired: Boolean): Either = wrapStorageRequest { userConfigStorage.persistSecondFactorPasswordChallengeStatus(isRequired) diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigMapper.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigMapper.kt index 110da73387e..6e58e177dff 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigMapper.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigMapper.kt @@ -131,7 +131,8 @@ class FeatureConfigMapperImpl : FeatureConfigMapper { override fun fromDTO(data: FeatureConfigData.ConferenceCalling): ConferenceCallingModel = ConferenceCallingModel( - status = fromDTO(data.status) + status = fromDTO(data.status), + useSFTForOneOnOneCalls = data.config.useSFTForOneToOneCalls ) override fun fromDTO(data: FeatureConfigData.E2EI?): E2EIModel = diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/SyncFeatureConfigsUseCase.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/SyncFeatureConfigsUseCase.kt index 9299f7a54f7..3ab938a9753 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/SyncFeatureConfigsUseCase.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/SyncFeatureConfigsUseCase.kt @@ -71,7 +71,7 @@ internal class SyncFeatureConfigsUseCaseImpl( conferenceCallingConfigHandler.handle(it.conferenceCallingModel) passwordChallengeConfigHandler.handle(it.secondFactorPasswordChallengeModel) selfDeletingMessagesConfigHandler.handle(it.selfDeletingMessagesModel) - it.e2EIModel?.let { e2EIModel -> e2EIConfigHandler.handle(e2EIModel) } + it.e2EIModel.let { e2EIModel -> e2EIConfigHandler.handle(e2EIModel) } appLockConfigHandler.handle(it.appLockModel) Either.Right(Unit) }.onFailure { networkFailure -> diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/ConferenceCallingConfigHandler.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/ConferenceCallingConfigHandler.kt index 673aa533ca8..c014dbfbfe8 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/ConferenceCallingConfigHandler.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/ConferenceCallingConfigHandler.kt @@ -22,12 +22,16 @@ import com.wire.kalium.logic.configuration.UserConfigRepository import com.wire.kalium.logic.data.featureConfig.ConferenceCallingModel import com.wire.kalium.logic.data.featureConfig.Status import com.wire.kalium.logic.functional.Either +import com.wire.kalium.logic.functional.flatMap class ConferenceCallingConfigHandler( private val userConfigRepository: UserConfigRepository ) { fun handle(conferenceCallingConfig: ConferenceCallingModel): Either { val conferenceCallingEnabled = conferenceCallingConfig.status == Status.ENABLED - return userConfigRepository.setConferenceCallingEnabled(conferenceCallingEnabled) + val result = userConfigRepository.setConferenceCallingEnabled(conferenceCallingEnabled).flatMap { + userConfigRepository.setUseSFTForOneOnOneCalls(conferenceCallingConfig.useSFTForOneOnOneCalls) + } + return result } } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/event/FeatureConfigMapperTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/event/FeatureConfigMapperTest.kt index 83986b6af7b..80e73517187 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/event/FeatureConfigMapperTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/event/FeatureConfigMapperTest.kt @@ -23,6 +23,7 @@ import com.wire.kalium.logic.data.featureConfig.FeatureConfigMapperImpl import com.wire.kalium.logic.data.featureConfig.Status import com.wire.kalium.network.api.authenticated.featureConfigs.AppLockConfigDTO import com.wire.kalium.network.api.authenticated.featureConfigs.ClassifiedDomainsConfigDTO +import com.wire.kalium.network.api.authenticated.featureConfigs.ConferenceCallingConfigDTO import com.wire.kalium.network.api.authenticated.featureConfigs.FeatureConfigData import com.wire.kalium.network.api.authenticated.featureConfigs.FeatureConfigResponse import com.wire.kalium.network.api.authenticated.featureConfigs.FeatureFlagStatusDTO @@ -141,7 +142,7 @@ class FeatureConfigMapperTest { ClassifiedDomainsConfigDTO(listOf("wire.com")), FeatureFlagStatusDTO.ENABLED ), - FeatureConfigData.ConferenceCalling(FeatureFlagStatusDTO.ENABLED), + FeatureConfigData.ConferenceCalling(FeatureFlagStatusDTO.ENABLED, ConferenceCallingConfigDTO(false)), FeatureConfigData.ConversationGuestLinks(FeatureFlagStatusDTO.ENABLED), FeatureConfigData.DigitalSignatures(FeatureFlagStatusDTO.ENABLED), FeatureConfigData.FileSharing(FeatureFlagStatusDTO.ENABLED), diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigRepositoryTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigRepositoryTest.kt index c4aeac2345b..1d1f62bdda4 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigRepositoryTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigRepositoryTest.kt @@ -25,6 +25,7 @@ import com.wire.kalium.logic.util.shouldFail import com.wire.kalium.logic.util.shouldSucceed import com.wire.kalium.network.api.authenticated.featureConfigs.AppLockConfigDTO import com.wire.kalium.network.api.authenticated.featureConfigs.ClassifiedDomainsConfigDTO +import com.wire.kalium.network.api.authenticated.featureConfigs.ConferenceCallingConfigDTO import com.wire.kalium.network.api.authenticated.featureConfigs.E2EIConfigDTO import com.wire.kalium.network.api.base.authenticated.featureConfigs.FeatureConfigApi import com.wire.kalium.network.api.authenticated.featureConfigs.FeatureConfigData @@ -59,7 +60,7 @@ class FeatureConfigRepositoryTest { ClassifiedDomainsConfigModel(listOf()), Status.ENABLED ), - ConferenceCallingModel(Status.ENABLED), + ConferenceCallingModel(Status.ENABLED, false), ConfigsStatusModel(Status.ENABLED), ConfigsStatusModel(Status.ENABLED), ConfigsStatusModel(Status.ENABLED), @@ -145,7 +146,7 @@ class FeatureConfigRepositoryTest { AppLockConfigDTO(true, 0), FeatureFlagStatusDTO.ENABLED ), FeatureConfigData.ClassifiedDomains(ClassifiedDomainsConfigDTO(listOf()), FeatureFlagStatusDTO.ENABLED), - FeatureConfigData.ConferenceCalling(FeatureFlagStatusDTO.ENABLED), + FeatureConfigData.ConferenceCalling(FeatureFlagStatusDTO.ENABLED, ConferenceCallingConfigDTO(false)), FeatureConfigData.ConversationGuestLinks(FeatureFlagStatusDTO.ENABLED), FeatureConfigData.DigitalSignatures(FeatureFlagStatusDTO.ENABLED), FeatureConfigData.FileSharing(FeatureFlagStatusDTO.ENABLED), diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigTest.kt index e1aadb92060..b70e743aea6 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/featureConfig/FeatureConfigTest.kt @@ -29,7 +29,7 @@ object FeatureConfigTest { ClassifiedDomainsConfigModel(listOf()), Status.ENABLED ), - conferenceCallingModel: ConferenceCallingModel = ConferenceCallingModel(Status.ENABLED), + conferenceCallingModel: ConferenceCallingModel = ConferenceCallingModel(Status.ENABLED, false), conversationGuestLinksModel: ConfigsStatusModel = ConfigsStatusModel(Status.ENABLED), digitalSignaturesModel: ConfigsStatusModel = ConfigsStatusModel(Status.ENABLED), fileSharingModel: ConfigsStatusModel = ConfigsStatusModel(Status.ENABLED), diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/SyncFeatureConfigsUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/SyncFeatureConfigsUseCaseTest.kt index 9c47261cdae..78e0efaaa4e 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/SyncFeatureConfigsUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/SyncFeatureConfigsUseCaseTest.kt @@ -119,7 +119,7 @@ class SyncFeatureConfigsUseCaseTest { fun givenConferenceCallingIsEnabled_whenSyncing_thenItShouldBeStoredAsEnabled() = runTest { val (arrangement, syncFeatureConfigsUseCase) = Arrangement() .withRemoteFeatureConfigsSucceeding( - FeatureConfigTest.newModel(conferenceCallingModel = ConferenceCallingModel(Status.ENABLED)) + FeatureConfigTest.newModel(conferenceCallingModel = ConferenceCallingModel(Status.ENABLED, false)) ) .withGetTeamSettingsSelfDeletionStatusSuccessful() .withGetSupportedProtocolsReturning(null) @@ -136,7 +136,7 @@ class SyncFeatureConfigsUseCaseTest { fun givenConferenceCallingIsDisasbled_whenSyncing_thenItShouldBeStoredAsDisabled() = runTest { val (arrangement, syncFeatureConfigsUseCase) = Arrangement() .withRemoteFeatureConfigsSucceeding( - FeatureConfigTest.newModel(conferenceCallingModel = ConferenceCallingModel(Status.DISABLED)) + FeatureConfigTest.newModel(conferenceCallingModel = ConferenceCallingModel(Status.DISABLED, false)) ) .withGetTeamSettingsSelfDeletionStatusSuccessful() .withGetSupportedProtocolsReturning(null) diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/ConferenceCallingConfigHandlerTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/ConferenceCallingConfigHandlerTest.kt new file mode 100644 index 00000000000..5160a23d614 --- /dev/null +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/ConferenceCallingConfigHandlerTest.kt @@ -0,0 +1,141 @@ +/* + * 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.featureConfig.handler + +import com.wire.kalium.logic.StorageFailure +import com.wire.kalium.logic.configuration.UserConfigRepository +import com.wire.kalium.logic.data.featureConfig.ConferenceCallingModel +import com.wire.kalium.logic.data.featureConfig.Status +import com.wire.kalium.logic.functional.Either +import com.wire.kalium.logic.functional.isLeft +import com.wire.kalium.logic.functional.isRight +import io.mockative.Mock +import io.mockative.any +import io.mockative.every +import io.mockative.mock +import io.mockative.once +import io.mockative.verify +import kotlin.test.Test +import kotlin.test.assertTrue + +class ConferenceCallingConfigHandlerTest { + + @Test + fun givenUserConfigRepositoryFailureForConferenceCallingEnabled_whenHandlingTheEvent_ThenReturnFailure() { + val conferenceCallingModel = ConferenceCallingModel(Status.ENABLED, false) + val (arrangement, conferenceCallingConfigHandler) = Arrangement() + .withSetConferenceCallingEnabledFailure() + .arrange() + + val result = conferenceCallingConfigHandler.handle(conferenceCallingModel) + + verify { + arrangement.userConfigRepository.setConferenceCallingEnabled(conferenceCallingModel.status.toBoolean()) + }.wasInvoked(exactly = once) + + verify { + arrangement.userConfigRepository.setUseSFTForOneOnOneCalls(any()) + }.wasNotInvoked() + + assertTrue { result.isLeft() } + } + + @Test + fun givenUserConfigRepositoryFailureForUseSFTForOneOnOneCalls_whenHandlingTheEvent_ThenReturnFailure() { + val conferenceCallingModel = ConferenceCallingModel(Status.ENABLED, false) + val (arrangement, conferenceCallingConfigHandler) = Arrangement() + .withSetConferenceCallingEnabledSuccess() + .withSetUseSFTForOneOnOneCallsFailure() + .arrange() + + val result = conferenceCallingConfigHandler.handle(conferenceCallingModel) + + verify { + arrangement.userConfigRepository.setConferenceCallingEnabled(conferenceCallingModel.status.toBoolean()) + }.wasInvoked(exactly = once) + + verify { + arrangement.userConfigRepository.setUseSFTForOneOnOneCalls(any()) + }.wasInvoked(exactly = once) + + assertTrue { result.isLeft() } + } + + @Test + fun givenUserConfigRepositorySuccess_whenHandlingTheEvent_ThenReturnUnit() { + val conferenceCallingModel = ConferenceCallingModel(Status.ENABLED, false) + val (arrangement, conferenceCallingConfigHandler) = Arrangement() + .withSetConferenceCallingEnabledSuccess() + .withSetUseSFTForOneOnOneCallsSuccess() + .arrange() + + val result = conferenceCallingConfigHandler.handle(conferenceCallingModel) + + verify { + arrangement.userConfigRepository.setConferenceCallingEnabled(conferenceCallingModel.status.toBoolean()) + }.wasInvoked(exactly = once) + + verify { + arrangement.userConfigRepository.setUseSFTForOneOnOneCalls(any()) + }.wasInvoked(exactly = once) + + assertTrue { result.isRight() } + } + + private class Arrangement { + + @Mock + val userConfigRepository: UserConfigRepository = mock(UserConfigRepository::class) + + fun arrange() = run { + this@Arrangement to ConferenceCallingConfigHandler( + userConfigRepository = userConfigRepository + ) + } + + init { + every { + userConfigRepository.setAppLockStatus(any(), any(), any()) + }.returns(Either.Right(Unit)) + } + + fun withSetConferenceCallingEnabledFailure() = apply { + every { + userConfigRepository.setConferenceCallingEnabled(any()) + }.returns(Either.Left(StorageFailure.DataNotFound)) + } + + fun withSetConferenceCallingEnabledSuccess() = apply { + every { + userConfigRepository.setConferenceCallingEnabled(any()) + }.returns(Either.Right(Unit)) + } + + fun withSetUseSFTForOneOnOneCallsFailure() = apply { + every { + userConfigRepository.setUseSFTForOneOnOneCalls(any()) + }.returns(Either.Left(StorageFailure.DataNotFound)) + } + + fun withSetUseSFTForOneOnOneCallsSuccess() = apply { + every { + userConfigRepository.setUseSFTForOneOnOneCalls(any()) + }.returns(Either.Right(Unit)) + } + } +} diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/sync/receiver/FeatureConfigEventReceiverTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/sync/receiver/FeatureConfigEventReceiverTest.kt index 75a69328ceb..1c06a919b6a 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/sync/receiver/FeatureConfigEventReceiverTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/sync/receiver/FeatureConfigEventReceiverTest.kt @@ -112,35 +112,45 @@ class FeatureConfigEventReceiverTest { } @Test - fun givenConferenceCallingUpdatedEventGrantingAccess_whenProcessingEvent_ThenSetConferenceCallingEnabledToTrue() = runTest { + fun givenConferenceCallingEventEnabled_whenProcessingEvent_ThenSetConferenceCallingEnabledToTrueAndSetShouldUseSFTFlag() = runTest { val (arrangement, featureConfigEventReceiver) = Arrangement() + .withSetUseSFTForOneOnOneCallsSuccessful() .withSettingConferenceCallingEnabledSuccessful() .arrange() featureConfigEventReceiver.onEvent( - arrangement.newConferenceCallingUpdatedEvent(ConferenceCallingModel(Status.ENABLED)), + arrangement.newConferenceCallingUpdatedEvent(ConferenceCallingModel(Status.ENABLED, false)), TestEvent.liveDeliveryInfo ) verify { arrangement.userConfigRepository.setConferenceCallingEnabled(eq(true)) }.wasInvoked(once) + + verify { + arrangement.userConfigRepository.setUseSFTForOneOnOneCalls(eq(false)) + }.wasInvoked(once) } @Test - fun givenConferenceCallingUpdatedEventGrantingAccess_whenProcessingEvent_ThenSetConferenceCallingEnabledToFalse() = runTest { + fun givenConferenceCallingEventDisabled_whenProcessingEvent_ThenSetConferenceCallingEnabledToFalseOnly() = runTest { val (arrangement, featureConfigEventReceiver) = Arrangement() + .withSetUseSFTForOneOnOneCallsSuccessful() .withSettingConferenceCallingEnabledSuccessful() .arrange() featureConfigEventReceiver.onEvent( - event = arrangement.newConferenceCallingUpdatedEvent(ConferenceCallingModel(Status.DISABLED)), + event = arrangement.newConferenceCallingUpdatedEvent(ConferenceCallingModel(Status.DISABLED, false)), deliveryInfo = TestEvent.liveDeliveryInfo ) verify { arrangement.userConfigRepository.setConferenceCallingEnabled(eq(false)) }.wasInvoked(once) + + verify { + arrangement.userConfigRepository.setUseSFTForOneOnOneCalls(eq(true)) + }.wasNotInvoked() } @Test @@ -339,6 +349,12 @@ class FeatureConfigEventReceiverTest { }.returns(Either.Right(Unit)) } + fun withSetUseSFTForOneOnOneCallsSuccessful() = apply { + every { + userConfigRepository.setUseSFTForOneOnOneCalls(any()) + }.returns(Either.Right(Unit)) + } + fun withIsFileSharingEnabled(result: Either) = apply { every { userConfigRepository.isFileSharingEnabled() diff --git a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/FeatureConfigJson.kt b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/FeatureConfigJson.kt index b9c47553ad5..230e95360e2 100644 --- a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/FeatureConfigJson.kt +++ b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/FeatureConfigJson.kt @@ -20,6 +20,7 @@ package com.wire.kalium.mocks.responses import com.wire.kalium.network.api.authenticated.featureConfigs.AppLockConfigDTO import com.wire.kalium.network.api.authenticated.featureConfigs.ClassifiedDomainsConfigDTO +import com.wire.kalium.network.api.authenticated.featureConfigs.ConferenceCallingConfigDTO import com.wire.kalium.network.api.authenticated.featureConfigs.FeatureConfigData import com.wire.kalium.network.api.authenticated.featureConfigs.FeatureConfigData.AppLock import com.wire.kalium.network.api.authenticated.featureConfigs.FeatureConfigData.ClassifiedDomains @@ -64,6 +65,9 @@ object FeatureConfigJson { | "status": "enabled" | }, | "conferenceCalling": { + | "config": { + | "useSFTForOneToOneCalls": false + | }, | "status": "enabled" | }, | "conversationGuestLinks": { @@ -116,7 +120,7 @@ object FeatureConfigJson { AppLockConfigDTO(true, 0), FeatureFlagStatusDTO.ENABLED ), ClassifiedDomains(ClassifiedDomainsConfigDTO(listOf()), FeatureFlagStatusDTO.ENABLED), - ConferenceCalling(FeatureFlagStatusDTO.ENABLED), + ConferenceCalling(FeatureFlagStatusDTO.ENABLED, ConferenceCallingConfigDTO(false)), ConversationGuestLinks(FeatureFlagStatusDTO.ENABLED), DigitalSignatures(FeatureFlagStatusDTO.ENABLED), FileSharing(FeatureFlagStatusDTO.ENABLED), diff --git a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/FeatureConfigResponseJson.kt b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/FeatureConfigResponseJson.kt index d1b0825837b..d56af3ba048 100644 --- a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/FeatureConfigResponseJson.kt +++ b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/FeatureConfigResponseJson.kt @@ -19,6 +19,7 @@ package com.wire.kalium.mocks.responses import com.wire.kalium.network.api.authenticated.featureConfigs.AppLockConfigDTO import com.wire.kalium.network.api.authenticated.featureConfigs.ClassifiedDomainsConfigDTO +import com.wire.kalium.network.api.authenticated.featureConfigs.ConferenceCallingConfigDTO import com.wire.kalium.network.api.authenticated.featureConfigs.E2EIConfigDTO import com.wire.kalium.network.api.authenticated.featureConfigs.FeatureConfigData import com.wire.kalium.network.api.authenticated.featureConfigs.FeatureConfigResponse @@ -46,7 +47,7 @@ object FeatureConfigResponseJson { ClassifiedDomainsConfigDTO(listOf("wire.com")), FeatureFlagStatusDTO.ENABLED ), - FeatureConfigData.ConferenceCalling(FeatureFlagStatusDTO.ENABLED), + FeatureConfigData.ConferenceCalling(FeatureFlagStatusDTO.ENABLED, ConferenceCallingConfigDTO(false)), FeatureConfigData.ConversationGuestLinks(FeatureFlagStatusDTO.ENABLED), FeatureConfigData.DigitalSignatures(FeatureFlagStatusDTO.ENABLED), FeatureConfigData.FileSharing(FeatureFlagStatusDTO.ENABLED), diff --git a/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/featureConfigs/FeatureConfigResponse.kt b/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/featureConfigs/FeatureConfigResponse.kt index 657fe3c7e52..d7b03c79d95 100644 --- a/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/featureConfigs/FeatureConfigResponse.kt +++ b/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/featureConfigs/FeatureConfigResponse.kt @@ -68,6 +68,12 @@ enum class FeatureFlagStatusDTO { DISABLED; } +@Serializable +data class ConferenceCallingConfigDTO( + @SerialName("useSFTForOneToOneCalls") + val useSFTForOneToOneCalls: Boolean +) + @Serializable data class AppLockConfigDTO( @SerialName("enforceAppLock") @@ -155,7 +161,9 @@ sealed class FeatureConfigData { @Serializable data class ConferenceCalling( @SerialName("status") - val status: FeatureFlagStatusDTO + val status: FeatureFlagStatusDTO, + @SerialName("config") + val config: ConferenceCallingConfigDTO ) : FeatureConfigData() @SerialName("conversationGuestLinks") diff --git a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/config/UserConfigStorage.kt b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/config/UserConfigStorage.kt index 57c8866264b..b3542fb10f7 100644 --- a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/config/UserConfigStorage.kt +++ b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/config/UserConfigStorage.kt @@ -145,6 +145,10 @@ interface UserConfigStorage { */ fun isConferenceCallingEnabled(): Boolean + fun persistUseSftForOneOnOneCalls(shouldUse: Boolean) + + fun shouldUseSftForOneOnOneCalls(): Boolean + /** * Get the saved flag to know whether user's Read Receipts are currently enabled or not */ @@ -503,6 +507,16 @@ class UserConfigStorageImpl( DEFAULT_CONFERENCE_CALLING_ENABLED_VALUE ) + override fun persistUseSftForOneOnOneCalls(shouldUse: Boolean) { + kaliumPreferences.putBoolean(USE_SFT_FOR_ONE_ON_ONE_CALLS, shouldUse) + } + + override fun shouldUseSftForOneOnOneCalls(): Boolean = + kaliumPreferences.getBoolean( + USE_SFT_FOR_ONE_ON_ONE_CALLS, + DEFAULT_USE_SFT_FOR_ONE_ON_ONE_CALLS_VALUE + ) + override fun areReadReceiptsEnabled(): Flow = areReadReceiptsEnabledFlow .map { kaliumPreferences.getBoolean(ENABLE_READ_RECEIPTS, true) } .onStart { emit(kaliumPreferences.getBoolean(ENABLE_READ_RECEIPTS, true)) } @@ -577,8 +591,10 @@ class UserConfigStorageImpl( const val E2EI_SETTINGS = "end_to_end_identity_settings" const val E2EI_NOTIFICATION_TIME = "end_to_end_identity_notification_time" const val ENABLE_CONFERENCE_CALLING = "enable_conference_calling" + const val USE_SFT_FOR_ONE_ON_ONE_CALLS = "use_sft_for_one_on_one_calls" const val ENABLE_READ_RECEIPTS = "enable_read_receipts" const val DEFAULT_CONFERENCE_CALLING_ENABLED_VALUE = false + const val DEFAULT_USE_SFT_FOR_ONE_ON_ONE_CALLS_VALUE = false const val REQUIRE_SECOND_FACTOR_PASSWORD_CHALLENGE = "require_second_factor_password_challenge" const val ENABLE_SCREENSHOT_CENSORING = "enable_screenshot_censoring"