Skip to content

Commit c992874

Browse files
committed
[IDLE-500] 다중 디바이스 지원을 위해 FCM Token을 제거할 때 Device Token을 Body에 담도록 변경
1 parent d33c0ca commit c992874

File tree

10 files changed

+50
-36
lines changed

10 files changed

+50
-36
lines changed

.github/workflows/android_cd.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ jobs:
6464
- name: Build AAB for Firebase
6565
run: ./gradlew bundleRelease --stacktrace
6666

67+
- name: Upload AAB artifact
68+
uses: actions/upload-artifact@v3
69+
with:
70+
name: app-release.aab
71+
path: app/build/outputs/bundle/release/app-release.aab
72+
6773
- name: Build APK for Testing
6874
run: ./gradlew assembleRelease --stacktrace
6975

@@ -77,4 +83,4 @@ jobs:
7783
firebase appdistribution:distribute app/build/outputs/apk/release/app-release.apk \
7884
--app ${{ secrets.FIREBASE_APP_ID }} \
7985
--release-notes "~새로운 릴리즈 버전이 날라왔어용~" \
80-
--groups "세얼간이"
86+
--groups "세얼간이"

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ android {
1111
namespace = "com.idle.care"
1212

1313
defaultConfig {
14-
versionCode = 8
15-
versionName = "1.1.1"
14+
versionCode = 9
15+
versionName = "1.1.2"
1616
targetSdk = 34
1717

1818
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

core/data/src/main/java/com/idle/data/repository/auth/AuthRepositoryImpl.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import com.idle.network.model.auth.WithdrawalWorkerRequest
1818
import com.idle.network.model.token.TokenResponse
1919
import com.idle.network.source.auth.AuthDataSource
2020
import kotlinx.coroutines.Dispatchers
21-
import kotlinx.coroutines.async
2221
import kotlinx.coroutines.launch
2322
import kotlinx.coroutines.withContext
2423
import javax.inject.Inject
@@ -116,29 +115,29 @@ class AuthRepositoryImpl @Inject constructor(
116115
)
117116

118117
override suspend fun logoutWorker(): Result<Unit> {
119-
tokenRepository.deleteDeviceToken()
118+
tokenRepository.deleteDeviceToken(getDeviceToken())
120119

121120
return authDataSource.logoutWorker()
122121
.onSuccess { clearUserData() }
123122
}
124123

125124
override suspend fun logoutCenter(): Result<Unit> {
126-
tokenRepository.deleteDeviceToken()
125+
tokenRepository.deleteDeviceToken(getDeviceToken())
127126

128127
return authDataSource.logoutCenter()
129128
.onSuccess { clearUserData() }
130129
}
131130

132131
override suspend fun withdrawalCenter(reason: String, password: String): Result<Unit> {
133-
tokenRepository.deleteDeviceToken()
132+
tokenRepository.deleteDeviceToken(getDeviceToken())
134133

135134
return authDataSource.withdrawalCenter(
136135
WithdrawalCenterRequest(reason = reason, password = password)
137136
).onSuccess { clearUserData() }
138137
}
139138

140139
override suspend fun withdrawalWorker(reason: String): Result<Unit> {
141-
tokenRepository.deleteDeviceToken()
140+
tokenRepository.deleteDeviceToken(getDeviceToken())
142141

143142
return authDataSource.withdrawalWorker(WithdrawalWorkerRequest(reason))
144143
.onSuccess { clearUserData() }
@@ -163,10 +162,10 @@ class AuthRepositoryImpl @Inject constructor(
163162
) = withContext(Dispatchers.IO) {
164163
launch { tokenDataSource.setRefreshToken(tokenResponse.refreshToken) }
165164
launch { userInfoDataSource.setUserType(userType) }
166-
launch { tokenDataSource.setAccessToken(tokenResponse.accessToken) }
165+
launch { tokenDataSource.setAccessToken(tokenResponse.accessToken) }.join()
167166

168-
val deviceToken = async { getDeviceToken() }
169-
tokenRepository.postDeviceToken(deviceToken.await(), userType = userType)
167+
val deviceToken = getDeviceToken()
168+
tokenRepository.postDeviceToken(deviceToken, userType = userType)
170169
}
171170

172171
private suspend fun clearUserData() = withContext(Dispatchers.IO) {

core/data/src/main/java/com/idle/data/repository/auth/TokenRepositoryImpl.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package com.idle.data.repository.auth
22

33
import com.idle.datastore.datasource.TokenDataSource
44
import com.idle.domain.repositorry.auth.TokenRepository
5-
import com.idle.network.model.auth.FCMTokenRequest
5+
import com.idle.network.model.notification.DeleteFcmTokenRequest
6+
import com.idle.network.model.notification.PostFcmTokenRequest
67
import com.idle.network.source.notification.NotificationDataSource
78
import kotlinx.coroutines.Dispatchers
89
import kotlinx.coroutines.flow.first
@@ -19,11 +20,12 @@ class TokenRepositoryImpl @Inject constructor(
1920

2021
override suspend fun postDeviceToken(deviceToken: String, userType: String): Result<Unit> =
2122
notificationDataSource.postFCMToken(
22-
FCMTokenRequest(
23+
PostFcmTokenRequest(
2324
deviceToken = deviceToken,
2425
userType = userType,
2526
)
2627
)
2728

28-
override suspend fun deleteDeviceToken(): Result<Unit> = notificationDataSource.deleteFCMToken()
29+
override suspend fun deleteDeviceToken(deviceToken: String): Result<Unit> =
30+
notificationDataSource.deleteFCMToken(DeleteFcmTokenRequest(deviceToken))
2931
}

core/data/src/test/java/com/idle/data/repository/auth/AuthRepositoryImplTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class AuthRepositoryImplTest {
4444
coEvery { userInfoDataSource.clearUserInfo() } just Runs
4545
coEvery { authDataSource.getDeviceToken() } returns "testToken"
4646
coEvery { tokenRepository.postDeviceToken(any(), any()) } returns Result.success(Unit)
47-
coEvery { tokenRepository.deleteDeviceToken() } returns Result.success(Unit)
47+
coEvery { tokenRepository.deleteDeviceToken(any()) } returns Result.success(Unit)
4848
}
4949

5050
@Test
@@ -109,7 +109,7 @@ class AuthRepositoryImplTest {
109109
// Then
110110
assertTrue(result.isSuccess)
111111
coVerify { tokenDataSource.clearToken() }
112-
coVerify { tokenRepository.deleteDeviceToken() }
112+
coVerify { tokenRepository.deleteDeviceToken(any()) }
113113
coVerify { userInfoDataSource.clearUserType() }
114114
coVerify { userInfoDataSource.clearUserInfo() }
115115
}
@@ -125,7 +125,7 @@ class AuthRepositoryImplTest {
125125
// Then
126126
assertTrue(result.isSuccess)
127127
coVerify { tokenDataSource.clearToken() }
128-
coVerify { tokenRepository.deleteDeviceToken() }
128+
coVerify { tokenRepository.deleteDeviceToken(any()) }
129129
coVerify { userInfoDataSource.clearUserType() }
130130
coVerify { userInfoDataSource.clearUserInfo() }
131131
}
@@ -141,7 +141,7 @@ class AuthRepositoryImplTest {
141141
// Then
142142
assertTrue(result.isSuccess)
143143
coVerify { tokenDataSource.clearToken() }
144-
coVerify { tokenRepository.deleteDeviceToken() }
144+
coVerify { tokenRepository.deleteDeviceToken(any()) }
145145
coVerify { userInfoDataSource.clearUserType() }
146146
coVerify { userInfoDataSource.clearUserInfo() }
147147
}
@@ -157,7 +157,7 @@ class AuthRepositoryImplTest {
157157
// Then
158158
assertTrue(result.isSuccess)
159159
coVerify { tokenDataSource.clearToken() }
160-
coVerify { tokenRepository.deleteDeviceToken() }
160+
coVerify { tokenRepository.deleteDeviceToken(any()) }
161161
coVerify { userInfoDataSource.clearUserType() }
162162
coVerify { userInfoDataSource.clearUserInfo() }
163163
}

core/domain/src/main/kotlin/com/idle/domain/repositorry/auth/TokenRepository.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.idle.domain.repositorry.auth
22

33
interface TokenRepository {
44
suspend fun getAccessToken(): String
5-
65
suspend fun postDeviceToken(deviceToken: String, userType: String): Result<Unit>
7-
suspend fun deleteDeviceToken(): Result<Unit>
6+
suspend fun deleteDeviceToken(deviceToken: String): Result<Unit>
87
}
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
package com.idle.network.api
22

3-
import com.idle.network.model.auth.FCMTokenRequest
3+
import com.idle.network.model.notification.DeleteFcmTokenRequest
44
import com.idle.network.model.notification.GetMyNotificationResponse
55
import com.idle.network.model.notification.GetUnreadNotificationCountResponse
6+
import com.idle.network.model.notification.PostFcmTokenRequest
67
import retrofit2.Response
78
import retrofit2.http.Body
8-
import retrofit2.http.DELETE
99
import retrofit2.http.GET
10+
import retrofit2.http.HTTP
1011
import retrofit2.http.PATCH
1112
import retrofit2.http.POST
1213
import retrofit2.http.Path
1314
import retrofit2.http.Query
1415

1516
interface NotificationApi {
1617
@POST("/api/v1/fcm/token")
17-
suspend fun postFCMToken(@Body fcmTokenRequest: FCMTokenRequest): Response<Unit>
18+
suspend fun postFCMToken(@Body postFcmTokenRequest: PostFcmTokenRequest): Response<Unit>
1819

19-
@PATCH("/api/v1/fcm/token")
20-
suspend fun patchFCMToken(@Body fcmTokenRequest: FCMTokenRequest): Response<Unit>
21-
22-
@DELETE("/api/v1/fcm/token")
23-
suspend fun deleteFCMToken(): Response<Unit>
20+
@HTTP(method = "DELETE", path = "/api/v1/fcm/token", hasBody = true)
21+
suspend fun deleteFCMToken(@Body deleteFcmTokenRequest: DeleteFcmTokenRequest): Response<Unit>
2422

2523
@GET("/api/v1/notifications/my")
2624
suspend fun getMyNotifications(
@@ -33,4 +31,4 @@ interface NotificationApi {
3331

3432
@GET("/api/v1/notifications/count")
3533
suspend fun getUnreadNotificationCount(): Response<GetUnreadNotificationCountResponse>
36-
}
34+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.idle.network.model.notification
2+
3+
import kotlinx.serialization.Serializable
4+
5+
@Serializable
6+
data class DeleteFcmTokenRequest(
7+
val deviceToken: String,
8+
)

core/network/src/main/java/com/idle/network/model/auth/FCMTokenRequest.kt renamed to core/network/src/main/java/com/idle/network/model/notification/PostFcmTokenRequest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package com.idle.network.model.auth
1+
package com.idle.network.model.notification
22

33
import kotlinx.serialization.Serializable
44

55
@Serializable
6-
data class FCMTokenRequest(
6+
data class PostFcmTokenRequest(
77
val deviceToken: String,
88
val userType: String,
99
)

core/network/src/main/java/com/idle/network/source/notification/NotificationDataSource.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package com.idle.network.source.notification
22

33
import com.idle.network.api.NotificationApi
4-
import com.idle.network.model.auth.FCMTokenRequest
4+
import com.idle.network.model.notification.DeleteFcmTokenRequest
5+
import com.idle.network.model.notification.PostFcmTokenRequest
56
import com.idle.network.model.notification.GetMyNotificationResponse
67
import com.idle.network.model.notification.GetUnreadNotificationCountResponse
78
import com.idle.network.util.safeApiCall
@@ -12,10 +13,11 @@ import javax.inject.Singleton
1213
class NotificationDataSource @Inject constructor(
1314
private val notificationApi: NotificationApi
1415
) {
15-
suspend fun postFCMToken(fcmTokenRequest: FCMTokenRequest): Result<Unit> =
16-
safeApiCall { notificationApi.postFCMToken(fcmTokenRequest) }
16+
suspend fun postFCMToken(postFcmTokenRequest: PostFcmTokenRequest): Result<Unit> =
17+
safeApiCall { notificationApi.postFCMToken(postFcmTokenRequest) }
1718

18-
suspend fun deleteFCMToken(): Result<Unit> = safeApiCall { notificationApi.deleteFCMToken() }
19+
suspend fun deleteFCMToken(deleteFcmTokenRequest: DeleteFcmTokenRequest): Result<Unit> =
20+
safeApiCall { notificationApi.deleteFCMToken(deleteFcmTokenRequest) }
1921

2022
suspend fun getMyNotifications(
2123
next: String?,

0 commit comments

Comments
 (0)