Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IDLE-461] 유저가 다중 디바이스에서 알림을 받을 수 있도록 개선한다. #207

Merged
merged 10 commits into from
Oct 23, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ class CarerApplyFacadeService(
}
}

centerManagers?.map { centerManager ->
val deviceToken = deviceTokenService.findByUserId(centerManager.id)
centerManagers?.forEach { centerManager ->
val deviceTokens = deviceTokenService.findAllByUserId(centerManager.id)
Comment on lines +62 to +63
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

널 안전성 개선이 필요합니다

deviceTokenService.findAllByUserId가 null을 반환할 수 있는 상황에 대해 더 명시적인 처리가 필요합니다. 빈 리스트를 반환하는 것이 더 안전한 방식일 수 있습니다.

다음과 같이 수정하는 것을 제안드립니다:

-        centerManagers?.forEach { centerManager ->
-            val deviceTokens = deviceTokenService.findAllByUserId(centerManager.id)
+        centerManagers?.forEach { centerManager ->
+            val deviceTokens = deviceTokenService.findAllByUserId(centerManager.id).orEmpty()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
centerManagers?.forEach { centerManager ->
val deviceTokens = deviceTokenService.findAllByUserId(centerManager.id)
centerManagers?.forEach { centerManager ->
val deviceTokens = deviceTokenService.findAllByUserId(centerManager.id).orEmpty()


if (deviceToken != null) {
deviceTokens?.forEach { deviceToken ->
val notificationInfo = CarerApplyNotificationInfo(
title = "${carer.name} 님이 공고에 지원하였습니다.",
body = createBodyMessage(jobPosting),
Expand All @@ -85,6 +85,7 @@ class CarerApplyFacadeService(
}
}
}

carerApplyService.create(jobPostingId, carer.id, applyMethodType)
}

Expand All @@ -98,4 +99,5 @@ class CarerApplyFacadeService(
"${BirthYear.calculateAge(jobPosting.birthYear)}세 " +
jobPosting.gender.value
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class DeviceTokenService(
return deviceTokenJpaRepository.findByDeviceToken(deviceToken)
}

fun findByUserId(userId: UUID): DeviceToken? {
return deviceTokenJpaRepository.findByUserId(userId)
fun findAllByUserId(userId: UUID): List<DeviceToken>? {
return deviceTokenJpaRepository.findAllByUserId(userId)
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ interface DeviceTokenJpaRepository : JpaRepository<DeviceToken, UUID> {

fun findByUserId(userId: UUID): DeviceToken?

fun findAllByUserId(userId: UUID): List<DeviceToken>?

}
Loading