parent
a26bb19b0f
commit
b04f35c2da
|
@ -5,8 +5,11 @@ import kr.co.vividnext.sodalive.admin.audition.role.AdminAuditionRoleRepository
|
||||||
import kr.co.vividnext.sodalive.audition.AuditionStatus
|
import kr.co.vividnext.sodalive.audition.AuditionStatus
|
||||||
import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
|
import kr.co.vividnext.sodalive.fcm.FcmEvent
|
||||||
|
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
||||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
import kr.co.vividnext.sodalive.utils.generateFileName
|
||||||
import org.springframework.beans.factory.annotation.Value
|
import org.springframework.beans.factory.annotation.Value
|
||||||
|
import org.springframework.context.ApplicationEventPublisher
|
||||||
import org.springframework.data.repository.findByIdOrNull
|
import org.springframework.data.repository.findByIdOrNull
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import org.springframework.transaction.annotation.Transactional
|
import org.springframework.transaction.annotation.Transactional
|
||||||
|
@ -18,6 +21,7 @@ class AdminAuditionService(
|
||||||
private val objectMapper: ObjectMapper,
|
private val objectMapper: ObjectMapper,
|
||||||
private val repository: AdminAuditionRepository,
|
private val repository: AdminAuditionRepository,
|
||||||
private val roleRepository: AdminAuditionRoleRepository,
|
private val roleRepository: AdminAuditionRoleRepository,
|
||||||
|
private val applicationEventPublisher: ApplicationEventPublisher,
|
||||||
|
|
||||||
@Value("\${cloud.aws.s3.bucket}")
|
@Value("\${cloud.aws.s3.bucket}")
|
||||||
private val bucket: String
|
private val bucket: String
|
||||||
|
@ -82,6 +86,18 @@ class AdminAuditionService(
|
||||||
if (request.isActive != null) {
|
if (request.isActive != null) {
|
||||||
audition.isActive = request.isActive
|
audition.isActive = request.isActive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.status != null && request.status == AuditionStatus.IN_PROGRESS && audition.isActive) {
|
||||||
|
applicationEventPublisher.publishEvent(
|
||||||
|
FcmEvent(
|
||||||
|
type = FcmEventType.IN_PROGRESS_AUDITION,
|
||||||
|
title = "새로운 오디션 등록!",
|
||||||
|
message = "[${audition.title}]이 등록되었습니다. 지금 바로 오리지얼 오디오 드라마 오디션에 지원해보세요!",
|
||||||
|
isAuth = audition.isAdult,
|
||||||
|
auditionId = audition.id ?: -1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAuditionList(offset: Long, limit: Long): GetAuditionListResponse {
|
fun getAuditionList(offset: Long, limit: Long): GetAuditionListResponse {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.transaction.event.TransactionalEventListener
|
||||||
|
|
||||||
enum class FcmEventType {
|
enum class FcmEventType {
|
||||||
ALL, INDIVIDUAL, CREATE_LIVE, START_LIVE, CANCEL_LIVE, UPLOAD_CONTENT, SEND_MESSAGE, CHANGE_NOTICE,
|
ALL, INDIVIDUAL, CREATE_LIVE, START_LIVE, CANCEL_LIVE, UPLOAD_CONTENT, SEND_MESSAGE, CHANGE_NOTICE,
|
||||||
CREATE_CONTENT_COMMENT
|
CREATE_CONTENT_COMMENT, IN_PROGRESS_AUDITION
|
||||||
}
|
}
|
||||||
|
|
||||||
class FcmEvent(
|
class FcmEvent(
|
||||||
|
@ -25,6 +25,7 @@ class FcmEvent(
|
||||||
val contentId: Long? = null,
|
val contentId: Long? = null,
|
||||||
val messageId: Long? = null,
|
val messageId: Long? = null,
|
||||||
val creatorId: Long? = null,
|
val creatorId: Long? = null,
|
||||||
|
val auditionId: Long? = null,
|
||||||
val commentParentId: Long? = null,
|
val commentParentId: Long? = null,
|
||||||
val myMemberId: Long? = null,
|
val myMemberId: Long? = null,
|
||||||
val isAvailableJoinCreator: Boolean? = null
|
val isAvailableJoinCreator: Boolean? = null
|
||||||
|
@ -278,6 +279,41 @@ class FcmSendListener(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FcmEventType.IN_PROGRESS_AUDITION -> {
|
||||||
|
if (fcmEvent.auditionId != null && fcmEvent.auditionId > 0) {
|
||||||
|
val pushTokenList = memberRepository.getAuditionNoticeRecipientPushTokens(
|
||||||
|
isAuth = fcmEvent.isAuth ?: false
|
||||||
|
)
|
||||||
|
|
||||||
|
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",
|
||||||
|
auditionId = fcmEvent.auditionId
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aosPushToken != null) {
|
||||||
|
for (tokens in aosPushToken) {
|
||||||
|
pushService.send(
|
||||||
|
tokens = tokens,
|
||||||
|
title = fcmEvent.title,
|
||||||
|
message = fcmEvent.message,
|
||||||
|
container = "aos",
|
||||||
|
auditionId = fcmEvent.auditionId
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@ class FcmService {
|
||||||
roomId: Long? = null,
|
roomId: Long? = null,
|
||||||
messageId: Long? = null,
|
messageId: Long? = null,
|
||||||
contentId: Long? = null,
|
contentId: Long? = null,
|
||||||
creatorId: Long? = null
|
creatorId: Long? = null,
|
||||||
|
auditionId: Long? = null
|
||||||
) {
|
) {
|
||||||
if (tokens.isNotEmpty()) {
|
if (tokens.isNotEmpty()) {
|
||||||
logger.info("os: $container")
|
logger.info("os: $container")
|
||||||
|
@ -76,6 +77,10 @@ class FcmService {
|
||||||
multicastMessage.putData("channel_id", creatorId.toString())
|
multicastMessage.putData("channel_id", creatorId.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auditionId != null) {
|
||||||
|
multicastMessage.putData("auditionId", auditionId.toString())
|
||||||
|
}
|
||||||
|
|
||||||
val response = FirebaseMessaging.getInstance().sendEachForMulticast(multicastMessage.build())
|
val response = FirebaseMessaging.getInstance().sendEachForMulticast(multicastMessage.build())
|
||||||
logger.info("보내기 성공: ${response.successCount}")
|
logger.info("보내기 성공: ${response.successCount}")
|
||||||
logger.info("보내기 실패: ${response.failureCount}")
|
logger.info("보내기 실패: ${response.failureCount}")
|
||||||
|
|
|
@ -56,6 +56,7 @@ interface MemberQueryRepository {
|
||||||
|
|
||||||
fun getChangeNoticeRecipientPushTokens(creatorId: Long): Map<String, List<List<String>>>
|
fun getChangeNoticeRecipientPushTokens(creatorId: Long): Map<String, List<List<String>>>
|
||||||
fun getPushTokenFromReservationList(roomId: Long): Map<String, List<List<String>>>
|
fun getPushTokenFromReservationList(roomId: Long): Map<String, List<List<String>>>
|
||||||
|
fun getAuditionNoticeRecipientPushTokens(isAuth: Boolean): Map<String, List<List<String>>>
|
||||||
|
|
||||||
fun getMemberProfile(memberId: Long, myMemberId: Long): GetMemberProfileResponse
|
fun getMemberProfile(memberId: Long, myMemberId: Long): GetMemberProfileResponse
|
||||||
}
|
}
|
||||||
|
@ -427,6 +428,37 @@ class MemberQueryRepositoryImpl(
|
||||||
return mapOf("aos" to aosPushTokens, "ios" to iosPushTokens)
|
return mapOf("aos" to aosPushTokens, "ios" to iosPushTokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getAuditionNoticeRecipientPushTokens(isAuth: Boolean): Map<String, List<List<String>>> {
|
||||||
|
var where = memberNotification.audition.isTrue
|
||||||
|
.and(member.pushToken.isNotNull)
|
||||||
|
|
||||||
|
if (isAuth) {
|
||||||
|
where = where.and(auth.isNotNull)
|
||||||
|
}
|
||||||
|
|
||||||
|
val aosPushTokens = queryFactory
|
||||||
|
.select(member.pushToken)
|
||||||
|
.from(member)
|
||||||
|
.leftJoin(member.auth, auth)
|
||||||
|
.leftJoin(memberNotification).on(memberNotification.member.id.eq(member.id))
|
||||||
|
.where(where.and(member.container.eq("aos")))
|
||||||
|
.fetch()
|
||||||
|
.toSet()
|
||||||
|
.chunked(500)
|
||||||
|
|
||||||
|
val iosPushTokens = queryFactory
|
||||||
|
.select(member.pushToken)
|
||||||
|
.from(member)
|
||||||
|
.leftJoin(member.auth, auth)
|
||||||
|
.leftJoin(memberNotification).on(memberNotification.member.id.eq(member.id))
|
||||||
|
.where(where.and(member.container.eq("ios")))
|
||||||
|
.fetch()
|
||||||
|
.toSet()
|
||||||
|
.chunked(500)
|
||||||
|
|
||||||
|
return mapOf("aos" to aosPushTokens, "ios" to iosPushTokens)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getMemberProfile(memberId: Long, myMemberId: Long): GetMemberProfileResponse {
|
override fun getMemberProfile(memberId: Long, myMemberId: Long): GetMemberProfileResponse {
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
|
|
|
@ -17,7 +17,10 @@ data class MemberNotification(
|
||||||
var live: Boolean? = true,
|
var live: Boolean? = true,
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
var message: Boolean? = true
|
var message: Boolean? = true,
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
var audition: Boolean? = false
|
||||||
) : BaseEntity() {
|
) : BaseEntity() {
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "member_id", nullable = false)
|
@JoinColumn(name = "member_id", nullable = false)
|
||||||
|
|
Loading…
Reference in New Issue