From 337eaa891992f06cb76928b81f4810e045e242f6 Mon Sep 17 00:00:00 2001 From: Damian Kaczmarek Date: Fri, 4 Oct 2024 08:20:36 +0200 Subject: [PATCH 1/6] feat: Add debug button send FCM token --- .../kalium/logic/feature/UserSessionScope.kt | 1 + .../kalium/logic/feature/debug/DebugScope.kt | 26 ++- .../notificationToken/SendFCMTokenUseCase.kt | 91 ++++++++++ .../SendFCMTokenToAPIUseCaseTest.kt | 160 ++++++++++++++++++ 4 files changed, 276 insertions(+), 2 deletions(-) create mode 100644 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt create mode 100644 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt index 0a1604a92e4..bd55eb46224 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt @@ -1805,6 +1805,7 @@ class UserSessionScope internal constructor( staleEpochVerifier, eventProcessor, legalHoldHandler, + globalPreferences, this, userScopedLogger, ) diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/debug/DebugScope.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/debug/DebugScope.kt index d86bd11b89b..325dbfe85e6 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/debug/DebugScope.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/debug/DebugScope.kt @@ -20,6 +20,8 @@ package com.wire.kalium.logic.feature.debug import com.wire.kalium.logger.KaliumLogger import com.wire.kalium.logic.cache.SelfConversationIdProvider +import com.wire.kalium.logic.configuration.notification.NotificationTokenDataSource +import com.wire.kalium.logic.configuration.notification.NotificationTokenRepository import com.wire.kalium.logic.data.asset.AssetRepository import com.wire.kalium.logic.data.client.ClientRepository import com.wire.kalium.logic.data.client.MLSClientProvider @@ -54,10 +56,13 @@ import com.wire.kalium.logic.feature.message.StaleEpochVerifier import com.wire.kalium.logic.feature.message.ephemeral.DeleteEphemeralMessageForSelfUserAsReceiverUseCaseImpl import com.wire.kalium.logic.feature.message.ephemeral.DeleteEphemeralMessageForSelfUserAsSenderUseCaseImpl import com.wire.kalium.logic.feature.message.ephemeral.EphemeralMessageDeletionHandlerImpl +import com.wire.kalium.logic.feature.notificationToken.SendFCMTokenUseCase +import com.wire.kalium.logic.feature.notificationToken.SendFCMTokenToAPIUseCaseImpl import com.wire.kalium.logic.sync.SyncManager import com.wire.kalium.logic.sync.incremental.EventProcessor import com.wire.kalium.logic.sync.receiver.handler.legalhold.LegalHoldHandler import com.wire.kalium.logic.util.MessageContentEncoder +import com.wire.kalium.persistence.kmmSettings.GlobalPrefProvider import com.wire.kalium.util.KaliumDispatcher import com.wire.kalium.util.KaliumDispatcherImpl import kotlinx.coroutines.CoroutineScope @@ -87,8 +92,9 @@ class DebugScope internal constructor( private val staleEpochVerifier: StaleEpochVerifier, private val eventProcessor: EventProcessor, private val legalHoldHandler: LegalHoldHandler, + private val globalPreferences: GlobalPrefProvider, private val scope: CoroutineScope, - private val logger: KaliumLogger, + logger: KaliumLogger, internal val dispatcher: KaliumDispatcher = KaliumDispatcherImpl, ) { @@ -179,7 +185,12 @@ class DebugScope internal constructor( messageSendingInterceptor, userRepository, staleEpochVerifier, - { message, expirationData -> ephemeralMessageDeletionHandler.enqueueSelfDeletion(message, expirationData) }, + { message, expirationData -> + ephemeralMessageDeletionHandler.enqueueSelfDeletion( + message, + expirationData + ) + }, scope ) @@ -208,4 +219,15 @@ class DebugScope internal constructor( selfUserId = userId, kaliumLogger = logger ) + + private val notificationTokenRepository: NotificationTokenRepository + get() = + NotificationTokenDataSource(globalPreferences.tokenStorage) + + val sendFCMTokenToServer: SendFCMTokenUseCase + get() = SendFCMTokenToAPIUseCaseImpl( + currentClientIdProvider, + clientRepository, + notificationTokenRepository, + ) } diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt new file mode 100644 index 00000000000..8f388442215 --- /dev/null +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt @@ -0,0 +1,91 @@ +/* + * 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.notificationToken + +import com.wire.kalium.logic.configuration.notification.NotificationTokenRepository +import com.wire.kalium.logic.data.client.ClientRepository +import com.wire.kalium.logic.data.id.CurrentClientIdProvider +import com.wire.kalium.logic.functional.Either +import com.wire.kalium.logic.functional.fold +import com.wire.kalium.network.api.model.PushTokenBody + +/** + * Sends to the API locally stored FCM push token + */ +interface SendFCMTokenUseCase { + suspend operator fun invoke(): Either +} + +data class SendFCMTokenError( + val status: Reason, + val error: String? = null, +) { + enum class Reason { + CANT_GET_CLIENT_ID, CANT_GET_NOTIFICATION_TOKEN, CANT_REGISTER_TOKEN, + } +} + +class SendFCMTokenToAPIUseCaseImpl( + private val currentClientIdProvider: CurrentClientIdProvider, + private val clientRepository: ClientRepository, + private val notificationTokenRepository: NotificationTokenRepository, +) : SendFCMTokenUseCase { + + override suspend fun invoke(): Either { + val clientId = currentClientIdProvider().fold( + { + return Either.Left( + SendFCMTokenError( + SendFCMTokenError.Reason.CANT_GET_CLIENT_ID, + it.toString() + ) + ) + }, + { it.value } + ) + val notificationToken = notificationTokenRepository.getNotificationToken().fold( + { + return Either.Left( + SendFCMTokenError( + SendFCMTokenError.Reason.CANT_GET_NOTIFICATION_TOKEN, + it.toString() + ) + ) + }, + { it } + ) + return clientRepository.registerToken( + body = PushTokenBody( + senderId = notificationToken.applicationId, + client = clientId, + token = notificationToken.token, + transport = notificationToken.transport + ) + ).fold( + { + Either.Left( + SendFCMTokenError( + SendFCMTokenError.Reason.CANT_REGISTER_TOKEN, + it.toString() + ) + ) + }, + { Either.Right(Unit) } + ) + } +} diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt new file mode 100644 index 00000000000..b622cd5b27f --- /dev/null +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt @@ -0,0 +1,160 @@ +/* + * 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.notificationToken + +import com.wire.kalium.logic.CoreFailure +import com.wire.kalium.logic.NetworkFailure +import com.wire.kalium.logic.StorageFailure +import com.wire.kalium.logic.configuration.notification.NotificationToken +import com.wire.kalium.logic.configuration.notification.NotificationTokenRepository +import com.wire.kalium.logic.data.client.ClientRepository +import com.wire.kalium.logic.data.conversation.ClientId +import com.wire.kalium.logic.data.id.CurrentClientIdProvider +import com.wire.kalium.logic.functional.Either +import com.wire.kalium.logic.functional.fold +import io.mockative.Mock +import io.mockative.any +import io.mockative.coEvery +import io.mockative.every +import io.mockative.mock +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.fail + +class SendFCMTokenToAPIUseCaseTest { + @Test + fun whenInvokedAndSuccessfulResultInTokenRegistered() = runTest { + + val useCase = + Arrangement() + .withClientId() + .withNotificationToken() + .withClientRepositoryRegisterToken() + .arrange() + + val result = useCase.invoke() + assertEquals(Either.Right(Unit), result) + } + + @Test + fun whenInvokedAndFailureOnClientId() = runTest { + + val useCase = Arrangement() + .withClientIdFailure() + .arrange() + + val failReason = useCase.invoke().fold( + { it.status }, + { fail("Expected failure, but got success") } + ) + assertEquals(SendFCMTokenError.Reason.CANT_GET_CLIENT_ID, failReason) + + } + + @Test + fun whenInvokedAndFailureOnNotificationToken() = runTest { + + val useCase = Arrangement() + .withClientId() + .withNotificationTokenFailure() + .arrange() + + val failReason = useCase.invoke().fold( + { it.status }, + { fail("Expected failure, but got success") } + ) + assertEquals(SendFCMTokenError.Reason.CANT_GET_NOTIFICATION_TOKEN, failReason) + } + + @Test + fun whenInvokedAndFailureOnClientRepositoryRegisterToken() = runTest { + + val useCase = Arrangement() + .withClientId() + .withNotificationToken() + .withClientRepositoryRegisterTokenFailure() + .arrange() + + val failReason = useCase.invoke().fold( + { it.status }, + { fail("Expected failure, but got success") } + ) + assertEquals(SendFCMTokenError.Reason.CANT_REGISTER_TOKEN, failReason) + } + + + private class Arrangement { + + @Mock + private val currentClientIdProvider: CurrentClientIdProvider = + mock(CurrentClientIdProvider::class) + + @Mock + private val clientRepository: ClientRepository = mock(ClientRepository::class) + + @Mock + private val notificationTokenRepository: NotificationTokenRepository = + mock(NotificationTokenRepository::class) + + + fun arrange(): SendFCMTokenToAPIUseCaseImpl { + return SendFCMTokenToAPIUseCaseImpl( + currentClientIdProvider, clientRepository, notificationTokenRepository + ) + } + + suspend fun withClientId() = apply { + coEvery { + currentClientIdProvider.invoke() + }.returns(Either.Right(ClientId("clientId"))) + } + + suspend fun withClientIdFailure() = apply { + coEvery { + currentClientIdProvider.invoke() + }.returns(Either.Left(CoreFailure.MissingClientRegistration)) + } + + fun withNotificationToken() = apply { + every { + notificationTokenRepository.getNotificationToken() + }.returns(Either.Right(NotificationToken("applicationId", "token", "transport"))) + } + + fun withNotificationTokenFailure() = apply { + every { + notificationTokenRepository.getNotificationToken() + }.returns(Either.Left(StorageFailure.DataNotFound)) + } + + suspend fun withClientRepositoryRegisterToken() = apply { + coEvery { + clientRepository.registerToken(any()) + }.returns(Either.Right(Unit)) + } + + suspend fun withClientRepositoryRegisterTokenFailure() = apply { + coEvery { + clientRepository.registerToken(any()) + }.returns(Either.Left(NetworkFailure.FeatureNotSupported)) + } + + } + +} From ceb678afaf498bf87d673f5e779b381f4c352dc6 Mon Sep 17 00:00:00 2001 From: Damian Kaczmarek Date: Fri, 4 Oct 2024 08:49:12 +0200 Subject: [PATCH 2/6] reduce returns --- .../notificationToken/SendFCMTokenUseCase.kt | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt index 8f388442215..7c3805dcf08 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt @@ -22,6 +22,8 @@ import com.wire.kalium.logic.data.client.ClientRepository import com.wire.kalium.logic.data.id.CurrentClientIdProvider import com.wire.kalium.logic.functional.Either import com.wire.kalium.logic.functional.fold +import com.wire.kalium.logic.functional.getOrNull +import com.wire.kalium.logic.functional.nullableFold import com.wire.kalium.network.api.model.PushTokenBody /** @@ -47,28 +49,26 @@ class SendFCMTokenToAPIUseCaseImpl( ) : SendFCMTokenUseCase { override suspend fun invoke(): Either { - val clientId = currentClientIdProvider().fold( + val clientIdResult = currentClientIdProvider() + val notificationTokenResult = notificationTokenRepository.getNotificationToken() + + val error: SendFCMTokenError? = clientIdResult.nullableFold( + { SendFCMTokenError(SendFCMTokenError.Reason.CANT_GET_CLIENT_ID, it.toString()) }, { - return Either.Left( - SendFCMTokenError( - SendFCMTokenError.Reason.CANT_GET_CLIENT_ID, - it.toString() - ) + notificationTokenResult.nullableFold( + { SendFCMTokenError(SendFCMTokenError.Reason.CANT_GET_NOTIFICATION_TOKEN, it.toString()) }, + { null } ) - }, - { it.value } - ) - val notificationToken = notificationTokenRepository.getNotificationToken().fold( - { - return Either.Left( - SendFCMTokenError( - SendFCMTokenError.Reason.CANT_GET_NOTIFICATION_TOKEN, - it.toString() - ) - ) - }, - { it } + } ) + + if (error != null) { + return Either.Left(error) + } + + val clientId = clientIdResult.getOrNull()!!.value + val notificationToken = notificationTokenResult.getOrNull()!! + return clientRepository.registerToken( body = PushTokenBody( senderId = notificationToken.applicationId, From 2d45178dacafb36776883f3dace57cc088c10ebe Mon Sep 17 00:00:00 2001 From: Damian Kaczmarek Date: Fri, 4 Oct 2024 09:26:29 +0200 Subject: [PATCH 3/6] fixed test --- .../feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt index b622cd5b27f..1c34536df0c 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt @@ -57,6 +57,7 @@ class SendFCMTokenToAPIUseCaseTest { val useCase = Arrangement() .withClientIdFailure() + .withNotificationToken() .arrange() val failReason = useCase.invoke().fold( From abb5bf005c73ae280db590976e8c5d8ac54ae119 Mon Sep 17 00:00:00 2001 From: Damian Kaczmarek Date: Fri, 4 Oct 2024 12:48:16 +0200 Subject: [PATCH 4/6] fix datadog report --- .../com/wire/kalium/logic/feature/UserSessionScope.kt | 2 +- .../com/wire/kalium/logic/feature/debug/DebugScope.kt | 8 +------- .../feature/notificationToken/SendFCMTokenUseCase.kt | 4 +++- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt index bd55eb46224..99e714d93db 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt @@ -1805,7 +1805,7 @@ class UserSessionScope internal constructor( staleEpochVerifier, eventProcessor, legalHoldHandler, - globalPreferences, + notificationTokenRepository, this, userScopedLogger, ) diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/debug/DebugScope.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/debug/DebugScope.kt index 325dbfe85e6..92d7176faaf 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/debug/DebugScope.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/debug/DebugScope.kt @@ -20,7 +20,6 @@ package com.wire.kalium.logic.feature.debug import com.wire.kalium.logger.KaliumLogger import com.wire.kalium.logic.cache.SelfConversationIdProvider -import com.wire.kalium.logic.configuration.notification.NotificationTokenDataSource import com.wire.kalium.logic.configuration.notification.NotificationTokenRepository import com.wire.kalium.logic.data.asset.AssetRepository import com.wire.kalium.logic.data.client.ClientRepository @@ -62,7 +61,6 @@ import com.wire.kalium.logic.sync.SyncManager import com.wire.kalium.logic.sync.incremental.EventProcessor import com.wire.kalium.logic.sync.receiver.handler.legalhold.LegalHoldHandler import com.wire.kalium.logic.util.MessageContentEncoder -import com.wire.kalium.persistence.kmmSettings.GlobalPrefProvider import com.wire.kalium.util.KaliumDispatcher import com.wire.kalium.util.KaliumDispatcherImpl import kotlinx.coroutines.CoroutineScope @@ -92,7 +90,7 @@ class DebugScope internal constructor( private val staleEpochVerifier: StaleEpochVerifier, private val eventProcessor: EventProcessor, private val legalHoldHandler: LegalHoldHandler, - private val globalPreferences: GlobalPrefProvider, + private val notificationTokenRepository: NotificationTokenRepository, private val scope: CoroutineScope, logger: KaliumLogger, internal val dispatcher: KaliumDispatcher = KaliumDispatcherImpl, @@ -220,10 +218,6 @@ class DebugScope internal constructor( kaliumLogger = logger ) - private val notificationTokenRepository: NotificationTokenRepository - get() = - NotificationTokenDataSource(globalPreferences.tokenStorage) - val sendFCMTokenToServer: SendFCMTokenUseCase get() = SendFCMTokenToAPIUseCaseImpl( currentClientIdProvider, diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt index 7c3805dcf08..ca2e71ef47d 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt @@ -15,6 +15,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ +// Will be fixed in separate PR that will refactor clientRepository.registerToken to parameters list +@file:Suppress("konsist.useCasesShouldNotAccessNetworkLayerDirectly") package com.wire.kalium.logic.feature.notificationToken import com.wire.kalium.logic.configuration.notification.NotificationTokenRepository @@ -42,7 +44,7 @@ data class SendFCMTokenError( } } -class SendFCMTokenToAPIUseCaseImpl( +class SendFCMTokenToAPIUseCaseImpl internal constructor( private val currentClientIdProvider: CurrentClientIdProvider, private val clientRepository: ClientRepository, private val notificationTokenRepository: NotificationTokenRepository, From 9d7cb4d6cd86771c3d3950ade63f16c2d07eb6ec Mon Sep 17 00:00:00 2001 From: Damian Kaczmarek Date: Tue, 8 Oct 2024 10:34:28 +0200 Subject: [PATCH 5/6] after refactor fix --- .../notificationToken/SendFCMTokenUseCase.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt index ca2e71ef47d..653308ec700 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenUseCase.kt @@ -15,8 +15,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ -// Will be fixed in separate PR that will refactor clientRepository.registerToken to parameters list -@file:Suppress("konsist.useCasesShouldNotAccessNetworkLayerDirectly") package com.wire.kalium.logic.feature.notificationToken import com.wire.kalium.logic.configuration.notification.NotificationTokenRepository @@ -26,7 +24,6 @@ import com.wire.kalium.logic.functional.Either import com.wire.kalium.logic.functional.fold import com.wire.kalium.logic.functional.getOrNull import com.wire.kalium.logic.functional.nullableFold -import com.wire.kalium.network.api.model.PushTokenBody /** * Sends to the API locally stored FCM push token @@ -58,7 +55,12 @@ class SendFCMTokenToAPIUseCaseImpl internal constructor( { SendFCMTokenError(SendFCMTokenError.Reason.CANT_GET_CLIENT_ID, it.toString()) }, { notificationTokenResult.nullableFold( - { SendFCMTokenError(SendFCMTokenError.Reason.CANT_GET_NOTIFICATION_TOKEN, it.toString()) }, + { + SendFCMTokenError( + SendFCMTokenError.Reason.CANT_GET_NOTIFICATION_TOKEN, + it.toString() + ) + }, { null } ) } @@ -72,12 +74,10 @@ class SendFCMTokenToAPIUseCaseImpl internal constructor( val notificationToken = notificationTokenResult.getOrNull()!! return clientRepository.registerToken( - body = PushTokenBody( - senderId = notificationToken.applicationId, - client = clientId, - token = notificationToken.token, - transport = notificationToken.transport - ) + senderId = notificationToken.applicationId, + client = clientId, + token = notificationToken.token, + transport = notificationToken.transport ).fold( { Either.Left( From 2e5c7d61cbc0bcc393f75fde8b174cae96cdd298 Mon Sep 17 00:00:00 2001 From: Damian Kaczmarek Date: Tue, 8 Oct 2024 10:50:03 +0200 Subject: [PATCH 6/6] fix test --- .../feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt index 1c34536df0c..4b5c4637d88 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/notificationToken/SendFCMTokenToAPIUseCaseTest.kt @@ -146,13 +146,13 @@ class SendFCMTokenToAPIUseCaseTest { suspend fun withClientRepositoryRegisterToken() = apply { coEvery { - clientRepository.registerToken(any()) + clientRepository.registerToken(any(), any(), any(), any()) }.returns(Either.Right(Unit)) } suspend fun withClientRepositoryRegisterTokenFailure() = apply { coEvery { - clientRepository.registerToken(any()) + clientRepository.registerToken(any(), any(), any(), any()) }.returns(Either.Left(NetworkFailure.FeatureNotSupported)) }