From df7101df8040351784e518a19206813be41af60d Mon Sep 17 00:00:00 2001 From: eshc123 <> Date: Thu, 19 Dec 2024 17:22:56 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8,=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EA=B0=B1=EC=8B=A0=20API=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20-=20deviceIdentifier,=20osType=20=ED=95=84=EB=93=9C?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/repository/AuthRepositoryImpl.kt | 17 +++++++++----- .../core/data/common/DeviceInfoProvider.kt | 15 +++++++++++++ .../common/di/DeviceInfoProviderModule.kt | 22 +++++++++++++++++++ .../user/repository/UserRepositoryImpl.kt | 10 +++++++-- .../model/request/GoogleLoginRequest.kt | 3 ++- .../model/request/UpdateDeviceTokenRequest.kt | 4 +++- .../core/network/service/ProfileService.kt | 2 +- 7 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 core/data/common/src/main/java/com/goalpanzi/mission_mate/core/data/common/DeviceInfoProvider.kt create mode 100644 core/data/common/src/main/java/com/goalpanzi/mission_mate/core/data/common/di/DeviceInfoProviderModule.kt diff --git a/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/repository/AuthRepositoryImpl.kt b/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/repository/AuthRepositoryImpl.kt index de07cb95..493b1908 100644 --- a/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/repository/AuthRepositoryImpl.kt +++ b/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/repository/AuthRepositoryImpl.kt @@ -1,6 +1,7 @@ package com.goalpanzi.mission_mate.core.data.auth.repository import com.goalpanzi.mission_mate.core.data.auth.mapper.toModel +import com.goalpanzi.mission_mate.core.data.common.DeviceInfoProvider import com.goalpanzi.mission_mate.core.data.common.handleResult import com.goalpanzi.mission_mate.core.datastore.datasource.AuthDataSource import com.goalpanzi.mission_mate.core.domain.auth.repository.AuthRepository @@ -13,11 +14,15 @@ import javax.inject.Inject class AuthRepositoryImpl @Inject constructor( private val loginService: LoginService, - private val authDataSource: AuthDataSource -): AuthRepository { + private val authDataSource: AuthDataSource, + private val deviceInfoProvider: DeviceInfoProvider +) : AuthRepository { override suspend fun requestGoogleLogin(email: String) = handleResult { - val request = GoogleLoginRequest(email = email) + val request = GoogleLoginRequest( + email = email, + deviceIdentifier = deviceInfoProvider.getDeviceSSAID() + ) loginService.requestGoogleLogin(request) }.convert { it.toModel() @@ -35,7 +40,9 @@ class AuthRepositoryImpl @Inject constructor( override fun getRefreshToken(): Flow = authDataSource.getRefreshToken() - override fun setAccessToken(accessToken: String): Flow = authDataSource.setAccessToken(accessToken) + override fun setAccessToken(accessToken: String): Flow = + authDataSource.setAccessToken(accessToken) - override fun setRefreshToken(refreshToken: String): Flow = authDataSource.setRefreshToken(refreshToken) + override fun setRefreshToken(refreshToken: String): Flow = + authDataSource.setRefreshToken(refreshToken) } diff --git a/core/data/common/src/main/java/com/goalpanzi/mission_mate/core/data/common/DeviceInfoProvider.kt b/core/data/common/src/main/java/com/goalpanzi/mission_mate/core/data/common/DeviceInfoProvider.kt new file mode 100644 index 00000000..b9091c19 --- /dev/null +++ b/core/data/common/src/main/java/com/goalpanzi/mission_mate/core/data/common/DeviceInfoProvider.kt @@ -0,0 +1,15 @@ +package com.goalpanzi.mission_mate.core.data.common + +import android.annotation.SuppressLint +import android.content.Context +import android.provider.Settings +import javax.inject.Inject + +class DeviceInfoProvider @Inject constructor( + private val context: Context +) { + @SuppressLint("HardwareIds") + fun getDeviceSSAID(): String { + return Settings.Secure.getString(context.contentResolver,Settings.Secure.ANDROID_ID) + } +} diff --git a/core/data/common/src/main/java/com/goalpanzi/mission_mate/core/data/common/di/DeviceInfoProviderModule.kt b/core/data/common/src/main/java/com/goalpanzi/mission_mate/core/data/common/di/DeviceInfoProviderModule.kt new file mode 100644 index 00000000..32e87f90 --- /dev/null +++ b/core/data/common/src/main/java/com/goalpanzi/mission_mate/core/data/common/di/DeviceInfoProviderModule.kt @@ -0,0 +1,22 @@ +package com.goalpanzi.mission_mate.core.data.common.di + +import android.content.Context +import com.goalpanzi.mission_mate.core.data.common.DeviceInfoProvider +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@InstallIn(SingletonComponent::class) +@Module +object DeviceInfoProviderModule { + @Singleton + @Provides + fun provideADeviceInfoProvider( + @ApplicationContext context: Context + ): DeviceInfoProvider { + return DeviceInfoProvider(context) + } +} diff --git a/core/data/user/src/main/java/com/goalpanzi/mission_mate/core/data/user/repository/UserRepositoryImpl.kt b/core/data/user/src/main/java/com/goalpanzi/mission_mate/core/data/user/repository/UserRepositoryImpl.kt index d3f181a9..b114ca25 100644 --- a/core/data/user/src/main/java/com/goalpanzi/mission_mate/core/data/user/repository/UserRepositoryImpl.kt +++ b/core/data/user/src/main/java/com/goalpanzi/mission_mate/core/data/user/repository/UserRepositoryImpl.kt @@ -1,5 +1,6 @@ package com.goalpanzi.mission_mate.core.data.user.repository +import com.goalpanzi.mission_mate.core.data.common.DeviceInfoProvider import com.goalpanzi.mission_mate.core.data.common.handleResult import com.goalpanzi.mission_mate.core.data.common.mapper.toResponse import com.goalpanzi.mission_mate.core.data.user.FcmTokenManager @@ -20,7 +21,8 @@ import javax.inject.Inject class UserRepositoryImpl @Inject constructor( private val profileService: ProfileService, private val defaultDataSource: DefaultDataSource, - private val fcmTokenManager: FcmTokenManager + private val fcmTokenManager: FcmTokenManager, + private val deviceInfoProvider: DeviceInfoProvider ) : UserRepository { override suspend fun saveProfile( nickname: String, @@ -35,7 +37,11 @@ class UserRepositoryImpl @Inject constructor( } override suspend fun updateFcmToken(fcmToken: String): DomainResult = handleResult { - val request = UpdateDeviceTokenRequest(fcmToken) + val request = UpdateDeviceTokenRequest( + deviceToken = fcmToken, + deviceIdentifier = deviceInfoProvider.getDeviceSSAID(), + osType = "AOS" + ) profileService.updateDeviceToken(request) } diff --git a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/GoogleLoginRequest.kt b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/GoogleLoginRequest.kt index 675d11c4..54e5a61b 100644 --- a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/GoogleLoginRequest.kt +++ b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/GoogleLoginRequest.kt @@ -4,5 +4,6 @@ import kotlinx.serialization.Serializable @Serializable data class GoogleLoginRequest( - val email: String + val email: String, + val deviceIdentifier: String, ) diff --git a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/UpdateDeviceTokenRequest.kt b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/UpdateDeviceTokenRequest.kt index 4928d7d7..3a677c8f 100644 --- a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/UpdateDeviceTokenRequest.kt +++ b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/UpdateDeviceTokenRequest.kt @@ -4,5 +4,7 @@ import kotlinx.serialization.Serializable @Serializable data class UpdateDeviceTokenRequest( - val deviceToken: String + val deviceToken: String, + val deviceIdentifier: String, + val osType: String ) diff --git a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/service/ProfileService.kt b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/service/ProfileService.kt index 67500c39..4cb1ebd8 100644 --- a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/service/ProfileService.kt +++ b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/service/ProfileService.kt @@ -12,7 +12,7 @@ interface ProfileService { @Body request: SaveProfileRequest ): Response - @PATCH("/api/member/device-token") + @PATCH("/api/device/device-token") suspend fun updateDeviceToken( @Body request: UpdateDeviceTokenRequest ): Response