푸시메시지 기능 추가 - 전체, 개별, 라이브 생성, 라이브 시작, 메시지 전송, 콘텐츠 업로드
This commit is contained in:
@@ -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"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user