Skip to content

Commit

Permalink
DRAW-330 refactor: FcmService 추상화
Browse files Browse the repository at this point in the history
  • Loading branch information
comforest committed Sep 16, 2024
1 parent ce51522 commit 50715ce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<String, ConcurrentLinkedQueue<WaitingQueueSession>> = ConcurrentHashMap()

Expand All @@ -35,7 +35,7 @@ internal class MafiaGameWaitingQueueAdapter(

eventPublisher.publishEvent(event)
} else {
fcmService.quickStart(session)
pushMessageUseCase.quickStart(session)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.xorker.draw.notification

import com.xorker.draw.websocket.WaitingQueueSession

interface PushMessageUseCase {
fun quickStart(session: WaitingQueueSession)
}

0 comments on commit 50715ce

Please sign in to comment.