feat(fcm): 푸시 알림함 저장 및 카테고리 조회를 지원한다
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package kr.co.vividnext.sodalive.fcm
|
||||
|
||||
import kr.co.vividnext.sodalive.content.comment.AudioContentCommentRepository
|
||||
import kr.co.vividnext.sodalive.fcm.notification.PushNotificationCategory
|
||||
import kr.co.vividnext.sodalive.fcm.notification.PushNotificationService
|
||||
import kr.co.vividnext.sodalive.i18n.Lang
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
import kr.co.vividnext.sodalive.live.room.GenderRestriction
|
||||
@@ -27,10 +29,14 @@ enum class FcmDeepLinkValue(val value: String) {
|
||||
|
||||
class FcmEvent(
|
||||
val type: FcmEventType,
|
||||
val category: PushNotificationCategory? = null,
|
||||
val title: String = "",
|
||||
val message: String = "",
|
||||
val titleKey: String? = null,
|
||||
val messageKey: String? = null,
|
||||
val senderMemberId: Long? = null,
|
||||
val senderNicknameSnapshot: String? = null,
|
||||
val senderProfileImageSnapshot: String? = null,
|
||||
val args: List<Any> = listOf(),
|
||||
val container: String = "",
|
||||
val recipients: List<Long> = listOf(),
|
||||
@@ -54,7 +60,8 @@ class FcmSendListener(
|
||||
private val pushService: FcmService,
|
||||
private val memberRepository: MemberRepository,
|
||||
private val contentCommentRepository: AudioContentCommentRepository,
|
||||
private val messageSource: SodaMessageSource
|
||||
private val messageSource: SodaMessageSource,
|
||||
private val pushNotificationService: PushNotificationService
|
||||
) {
|
||||
@Async
|
||||
@TransactionalEventListener
|
||||
@@ -165,6 +172,13 @@ class FcmSendListener(
|
||||
val title = translate(fcmEvent.titleKey, fcmEvent.title, lang, fcmEvent.args)
|
||||
val message = translate(fcmEvent.messageKey, fcmEvent.message, lang, fcmEvent.args)
|
||||
|
||||
pushNotificationService.saveNotification(
|
||||
fcmEvent = fcmEvent,
|
||||
languageCode = lang.code,
|
||||
translatedMessage = message,
|
||||
recipientPushTokens = tokens
|
||||
)
|
||||
|
||||
val tokensByOS = tokens.groupBy { it.deviceType }
|
||||
for ((os, osTokens) in tokensByOS) {
|
||||
osTokens.map { it.token }.distinct().chunked(500).forEach { batch ->
|
||||
|
||||
Reference in New Issue
Block a user