크리에이터 채널 공지사항 변경 시 푸시 발송

This commit is contained in:
2023-08-25 22:42:23 +09:00
parent 0679fdfb6d
commit 41a6e05034
4 changed files with 92 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ import org.springframework.scheduling.annotation.Async
import org.springframework.stereotype.Component
enum class FcmEventType {
ALL, INDIVIDUAL, CREATE_LIVE, START_LIVE, UPLOAD_CONTENT, SEND_MESSAGE
ALL, INDIVIDUAL, CREATE_LIVE, START_LIVE, UPLOAD_CONTENT, SEND_MESSAGE, CHANGE_NOTICE
}
class FcmEvent(
@@ -156,6 +156,39 @@ class FcmSendListener(
messageId = fcmEvent.messageId
)
}
FcmEventType.CHANGE_NOTICE -> {
if (fcmEvent.creatorId != null) {
val pushTokenList = memberRepository.getChangeNoticeRecipientPushTokens(fcmEvent.creatorId)
val iosPushTokens = pushTokenList["ios"]
val aosPushToken = pushTokenList["aos"]
if (iosPushTokens != null) {
for (tokens in iosPushTokens) {
pushService.send(
tokens = tokens,
title = fcmEvent.title,
message = fcmEvent.message,
container = "ios",
creatorId = fcmEvent.creatorId
)
}
}
if (aosPushToken != null) {
for (tokens in aosPushToken) {
pushService.send(
tokens = tokens,
title = fcmEvent.title,
message = fcmEvent.message,
container = "aos",
creatorId = fcmEvent.creatorId
)
}
}
}
}
}
}
}

View File

@@ -19,7 +19,8 @@ class FcmService {
container: String,
roomId: Long? = null,
messageId: Long? = null,
contentId: Long? = null
contentId: Long? = null,
creatorId: Long? = null
) {
if (tokens.isNotEmpty()) {
logger.info("os: $container")
@@ -52,6 +53,10 @@ class FcmService {
multicastMessage.putData("content_id", contentId.toString())
}
if (creatorId != null) {
multicastMessage.putData("channel_id", creatorId.toString())
}
val response = FirebaseMessaging.getInstance().sendEachForMulticast(multicastMessage.build())
logger.info("보내기 성공: ${response.successCount}")
logger.info("보내기 실패: ${response.failureCount}")