feat(fcm): 채팅 푸시 payload를 확장한다

This commit is contained in:
2026-06-19 01:55:22 +09:00
parent 562a4b2077
commit 743020d6bf
3 changed files with 66 additions and 25 deletions

View File

@@ -33,7 +33,8 @@ class FcmService(
auditionId: Long? = null,
deepLinkValue: FcmDeepLinkValue? = null,
deepLinkId: Long? = null,
deepLinkCommentPostId: Long? = null
deepLinkCommentPostId: Long? = null,
chatType: String? = null
) {
if (tokens.isEmpty()) return
logger.info("os: $container")
@@ -70,30 +71,17 @@ class FcmService(
.build()
)
if (roomId != null) {
multicastMessage.putData("room_id", roomId.toString())
}
if (messageId != null) {
multicastMessage.putData("message_id", messageId.toString())
}
if (contentId != null) {
multicastMessage.putData("content_id", contentId.toString())
}
if (creatorId != null) {
multicastMessage.putData("channel_id", creatorId.toString())
}
if (auditionId != null) {
multicastMessage.putData("audition_id", auditionId.toString())
}
val deepLink = createDeepLink(deepLinkValue, deepLinkId, deepLinkCommentPostId)
if (deepLink != null) {
multicastMessage.putData("deep_link", deepLink)
}
multicastMessage.putAllData(
buildDataPayload(
roomId = roomId,
messageId = messageId,
contentId = contentId,
creatorId = creatorId,
auditionId = auditionId,
deepLink = createDeepLink(deepLinkValue, deepLinkId, deepLinkCommentPostId),
chatType = chatType
)
)
val response = FirebaseMessaging.getInstance().sendEachForMulticast(multicastMessage.build())
val failedTokens = mutableListOf<String>()
@@ -226,5 +214,29 @@ class FcmService(
return baseDeepLink
}
fun buildDataPayload(
roomId: Long? = null,
messageId: Long? = null,
contentId: Long? = null,
creatorId: Long? = null,
auditionId: Long? = null,
deepLinkValue: FcmDeepLinkValue? = null,
deepLinkId: Long? = null,
deepLinkCommentPostId: Long? = null,
deepLink: String? = null,
chatType: String? = null
): Map<String, String> {
val payload = mutableMapOf<String, String>()
if (roomId != null) payload["room_id"] = roomId.toString()
if (messageId != null) payload["message_id"] = messageId.toString()
if (chatType != null) payload["chat_type"] = chatType
if (contentId != null) payload["content_id"] = contentId.toString()
if (creatorId != null) payload["channel_id"] = creatorId.toString()
if (auditionId != null) payload["audition_id"] = auditionId.toString()
val resolvedDeepLink = deepLink ?: buildDeepLink("", deepLinkValue, deepLinkId, deepLinkCommentPostId)
if (resolvedDeepLink != null) payload["deep_link"] = resolvedDeepLink
return payload
}
}
}