From 50715ced091bf9cc70fcdda57fbd29c41136b5e5 Mon Sep 17 00:00:00 2001 From: HoYeon Lee Date: Mon, 16 Sep 2024 19:29:27 +0900 Subject: [PATCH] =?UTF-8?q?DRAW-330=20refactor:=20FcmService=20=EC=B6=94?= =?UTF-8?q?=EC=83=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/com/xorker/draw/firebase/FcmService.kt | 5 +++-- .../com/xorker/draw/mafia/MafiaGameWaitingQueueAdapter.kt | 6 +++--- .../com/xorker/draw/notification/PushMessageUseCase.kt | 7 +++++++ 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 domain/src/main/kotlin/com/xorker/draw/notification/PushMessageUseCase.kt diff --git a/adapter/firebase/src/main/kotlin/com/xorker/draw/firebase/FcmService.kt b/adapter/firebase/src/main/kotlin/com/xorker/draw/firebase/FcmService.kt index 370d407d..cf4f2700 100644 --- a/adapter/firebase/src/main/kotlin/com/xorker/draw/firebase/FcmService.kt +++ b/adapter/firebase/src/main/kotlin/com/xorker/draw/firebase/FcmService.kt @@ -3,6 +3,7 @@ package com.xorker.draw.firebase import com.google.firebase.messaging.FirebaseMessaging import com.google.firebase.messaging.Message import com.google.firebase.messaging.Notification +import com.xorker.draw.notification.PushMessageUseCase import com.xorker.draw.websocket.WaitingQueueSession import java.util.Locale import org.springframework.context.MessageSource @@ -11,9 +12,9 @@ import org.springframework.stereotype.Service @Service class FcmService( private val messageSource: MessageSource, -) { +) : PushMessageUseCase { - fun quickStart(session: WaitingQueueSession) { + override fun quickStart(session: WaitingQueueSession) { quickStart(session.locale, session.user.name) } diff --git a/adapter/memory/src/main/kotlin/com/xorker/draw/mafia/MafiaGameWaitingQueueAdapter.kt b/adapter/memory/src/main/kotlin/com/xorker/draw/mafia/MafiaGameWaitingQueueAdapter.kt index eb70b63d..c2748aaf 100644 --- a/adapter/memory/src/main/kotlin/com/xorker/draw/mafia/MafiaGameWaitingQueueAdapter.kt +++ b/adapter/memory/src/main/kotlin/com/xorker/draw/mafia/MafiaGameWaitingQueueAdapter.kt @@ -1,8 +1,8 @@ package com.xorker.draw.mafia import com.xorker.draw.exception.UnSupportedException -import com.xorker.draw.firebase.FcmService import com.xorker.draw.mafia.event.MafiaGameRandomMatchingEvent +import com.xorker.draw.notification.PushMessageUseCase import com.xorker.draw.websocket.WaitingQueueSession import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentLinkedQueue @@ -12,7 +12,7 @@ import org.springframework.stereotype.Component @Component internal class MafiaGameWaitingQueueAdapter( private val eventPublisher: ApplicationEventPublisher, - private val fcmService: FcmService, + private val pushMessageUseCase: PushMessageUseCase, ) : MafiaGameWaitingQueueRepository { private val waitingQueue: ConcurrentHashMap> = ConcurrentHashMap() @@ -35,7 +35,7 @@ internal class MafiaGameWaitingQueueAdapter( eventPublisher.publishEvent(event) } else { - fcmService.quickStart(session) + pushMessageUseCase.quickStart(session) } } } diff --git a/domain/src/main/kotlin/com/xorker/draw/notification/PushMessageUseCase.kt b/domain/src/main/kotlin/com/xorker/draw/notification/PushMessageUseCase.kt new file mode 100644 index 00000000..04ec870b --- /dev/null +++ b/domain/src/main/kotlin/com/xorker/draw/notification/PushMessageUseCase.kt @@ -0,0 +1,7 @@ +package com.xorker.draw.notification + +import com.xorker.draw.websocket.WaitingQueueSession + +interface PushMessageUseCase { + fun quickStart(session: WaitingQueueSession) +}