Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
feat(ReminderService): 알림 테스트를 위해 5분 단위로 알림 전송하도록 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
zbqmgldjfh committed Feb 4, 2024
1 parent 93891bb commit 840b467
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import com.google.firebase.messaging.Message
import com.google.firebase.messaging.Notification
import gdsc.plantory.event.FCMChannel
import org.slf4j.LoggerFactory
import org.springframework.context.event.EventListener
import org.springframework.scheduling.annotation.Async
import org.springframework.stereotype.Component
import org.springframework.transaction.event.TransactionPhase
import org.springframework.transaction.event.TransactionalEventListener

@Component
class WaterCycleEventListener(
Expand All @@ -22,8 +21,8 @@ class WaterCycleEventListener(
private val log = LoggerFactory.getLogger(WaterCycleEventListener::class.java)
}

@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
@Async
@EventListener
fun sendFcmNotification(events: WaterCycleEvents) {
val messages: List<Message> = createMessages(events.plantsNeedWateredToday, FCMChannel.WATER_ALERT.name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ReminderService(
private val companionPlantRepository: CompanionPlantRepository,
) {

@Scheduled(cron = "0 0 8 * * *")
@Scheduled(cron = "*/5 * * * *")
fun sendWaterNotification() {
val companionPlants = companionPlantRepository.findAllByNextWaterDate(LocalDate.now())
val events = WaterCycleEvents(buildWaterCycleEvents(companionPlants))
Expand Down

0 comments on commit 840b467

Please sign in to comment.