푸시메시지 기능 추가 - 전체, 개별, 라이브 생성, 라이브 시작, 메시지 전송, 콘텐츠 업로드

This commit is contained in:
2023-08-08 16:46:30 +09:00
parent 771dbeced0
commit 705bf0b6b2
13 changed files with 511 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
package kr.co.vividnext.sodalive.fcm
import org.springframework.context.ApplicationEventPublisher
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/push")
@PreAuthorize("hasRole('ADMIN')")
class FcmController(private val applicationEventPublisher: ApplicationEventPublisher) {
@PostMapping
fun send(
@RequestBody request: PushRequest
) = run {
if (request.memberIds.isNotEmpty()) {
applicationEventPublisher.publishEvent(
FcmEvent(
type = FcmEventType.INDIVIDUAL,
title = request.title,
message = request.message,
recipients = request.memberIds
)
)
} else {
applicationEventPublisher.publishEvent(
FcmEvent(
type = FcmEventType.ALL,
title = request.title,
message = request.message,
container = "ios"
)
)
applicationEventPublisher.publishEvent(
FcmEvent(
type = FcmEventType.ALL,
title = request.title,
message = request.message,
container = "aos"
)
)
}
}
}