Skip to content

Commit

Permalink
Merge pull request #335 from team-haribo/327-test-push-alert-api
Browse files Browse the repository at this point in the history
🔁 FCM 스케쥴 조건문 변경
  • Loading branch information
enbraining authored Dec 11, 2024
2 parents f445137 + 466ee14 commit aaaa311
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ class SendNotificationUseCase(
) {

fun execute(notificationType: NotificationType) {
val isExistTodayOutingDate = deniedOutingDateRepository.existsByOutingDate(LocalDate.now())
val isTodayDeniedOuting = deniedOutingDateRepository.existsByOutingDate(LocalDate.now())

when (notificationType) {
NotificationType.FIRST_NOTIFICATION -> {
runCatching {
notificationPort.sendNotification(
deviceTokens = deviceTokenRepository.findAll().map { it.token },
notificationConfig = NotificationConfig(
title = if(isExistTodayOutingDate) Topic.DENIED_NOTIFICATION.title
title = if(isTodayDeniedOuting) Topic.DENIED_NOTIFICATION.title
else Topic.FIRST_NOTIFICATION.title,
content = if(isExistTodayOutingDate) Topic.DENIED_NOTIFICATION.content
content = if(isTodayDeniedOuting) Topic.DENIED_NOTIFICATION.content
else Topic.FIRST_NOTIFICATION.content,
writer = Writer.GOMS
)
Expand All @@ -36,7 +36,7 @@ class SendNotificationUseCase(
}

NotificationType.FINAL_NOTIFICATION -> {
if(!isExistTodayOutingDate){
if(!isTodayDeniedOuting){
runCatching {
notificationPort.sendNotification(
deviceTokens = deviceTokenRepository.findAll().map { it.token },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@ class SetTodayOutingUseCase(
}

val nowDate = LocalDate.now()
val isExistDeniedOutingDate = deniedOutingDateRepository.existsByOutingDate(nowDate)
val isTodayDeniedOuting = deniedOutingDateRepository.existsByOutingDate(nowDate)

if(isExistDeniedOutingDate){
if(!setTodayOutingDto.outingStatus) deniedOutingDateRepository.deleteByOutingDate(nowDate)
if(isTodayDeniedOuting){
if(setTodayOutingDto.outingStatus) deniedOutingDateRepository.deleteByOutingDate(nowDate)
else throw DuplicatedOutingDateException()
} else {
if(setTodayOutingDto.outingStatus){
if(setTodayOutingDto.outingStatus) throw DuplicatedOutingDateException()
else {
val newDeniedOutingDate = DeniedOutingDate(
idx = -1,
outingDate = LocalDate.now()
)
deniedOutingDateRepository.save(newDeniedOutingDate)
} else throw DuplicatedOutingDateException()
}
}
}

Expand Down

0 comments on commit aaaa311

Please sign in to comment.