콘텐츠 댓글 알림 추가

This commit is contained in:
2023-08-28 15:26:27 +09:00
parent fb8309c7b4
commit cd833dc21d
4 changed files with 81 additions and 5 deletions

View File

@@ -1,12 +1,13 @@
package kr.co.vividnext.sodalive.fcm
import kr.co.vividnext.sodalive.content.comment.AudioContentCommentRepository
import kr.co.vividnext.sodalive.member.MemberRepository
import org.springframework.context.event.EventListener
import org.springframework.scheduling.annotation.Async
import org.springframework.stereotype.Component
import org.springframework.transaction.event.TransactionalEventListener
enum class FcmEventType {
ALL, INDIVIDUAL, CREATE_LIVE, START_LIVE, UPLOAD_CONTENT, SEND_MESSAGE, CHANGE_NOTICE
ALL, INDIVIDUAL, CREATE_LIVE, START_LIVE, UPLOAD_CONTENT, SEND_MESSAGE, CHANGE_NOTICE, CREATE_CONTENT_COMMENT
}
class FcmEvent(
@@ -19,16 +20,18 @@ class FcmEvent(
val roomId: Long? = null,
val contentId: Long? = null,
val messageId: Long? = null,
val creatorId: Long? = null
val creatorId: Long? = null,
val contentCommentId: Long? = null
)
@Component
class FcmSendListener(
private val pushService: FcmService,
private val memberRepository: MemberRepository
private val memberRepository: MemberRepository,
private val contentCommentRepository: AudioContentCommentRepository
) {
@Async
@EventListener
@TransactionalEventListener
fun send(fcmEvent: FcmEvent) {
when (fcmEvent.type) {
FcmEventType.ALL -> {
@@ -189,6 +192,24 @@ class FcmSendListener(
}
}
}
FcmEventType.CREATE_CONTENT_COMMENT -> {
if (fcmEvent.contentCommentId != null && fcmEvent.contentId != null) {
val response = contentCommentRepository.findPushTokenByContentCommentId(
contentCommentId = fcmEvent.contentCommentId
)
if (response != null) {
pushService.send(
tokens = listOf(response.pushToken),
title = fcmEvent.title,
message = fcmEvent.message,
container = response.container,
contentId = fcmEvent.contentId
)
}
}
}
}
}
}