콘텐츠 댓글의 답글 푸시

- AS-IS : 원 댓글의 글쓴이에게 알림(원 댓글 글쓴이가 답글을 달아도 알림)
- To-Be : 답글을 쓴 본인을 제외하고 원 댓글의 답글을 쓴 모든 유저에게 푸시 알림
This commit is contained in:
2023-11-27 20:35:08 +09:00
parent 11bb799bd5
commit f196b20024
5 changed files with 93 additions and 35 deletions

View File

@@ -25,7 +25,8 @@ class FcmEvent(
val contentId: Long? = null,
val messageId: Long? = null,
val creatorId: Long? = null,
val contentCommentId: Long? = null
val commentParentId: Long? = null,
val myMemberId: Long? = null
)
@Component
@@ -228,17 +229,45 @@ class FcmSendListener(
}
FcmEventType.CREATE_CONTENT_COMMENT -> {
if (fcmEvent.contentCommentId != null && fcmEvent.contentId != null) {
val response = contentCommentRepository.findPushTokenByContentCommentId(
contentCommentId = fcmEvent.contentCommentId
if (fcmEvent.myMemberId != null && fcmEvent.contentId != null) {
val response = contentCommentRepository.findPushTokenByContentIdAndCommentParentIdMyMemberId(
contentId = fcmEvent.contentId,
commentParentId = fcmEvent.commentParentId,
myMemberId = fcmEvent.myMemberId
)
if (response != null) {
val iosPushTokens = response
.asSequence()
.distinct()
.filter { it.pushToken.isNotBlank() }
.filter { it.container == "ios" }
.map { it.pushToken }
.toList()
val aosPushTokens = response
.asSequence()
.distinct()
.filter { it.pushToken.isNotBlank() }
.filter { it.container == "aos" }
.map { it.pushToken }
.toList()
if (iosPushTokens.isNotEmpty()) {
pushService.send(
tokens = listOf(response.pushToken),
tokens = iosPushTokens,
title = fcmEvent.title,
message = fcmEvent.message,
container = response.container,
container = "ios",
contentId = fcmEvent.contentId
)
}
if (aosPushTokens.isNotEmpty()) {
pushService.send(
tokens = aosPushTokens,
title = fcmEvent.title,
message = fcmEvent.message,
container = "aos",
contentId = fcmEvent.contentId
)
}