라이브 취소 푸시 발송 로직 추가
This commit is contained in:
parent
8f50d05906
commit
d6dfa63bea
|
@ -9,7 +9,8 @@ import org.springframework.transaction.annotation.Transactional
|
||||||
import org.springframework.transaction.event.TransactionalEventListener
|
import org.springframework.transaction.event.TransactionalEventListener
|
||||||
|
|
||||||
enum class FcmEventType {
|
enum class FcmEventType {
|
||||||
ALL, INDIVIDUAL, CREATE_LIVE, START_LIVE, UPLOAD_CONTENT, SEND_MESSAGE, CHANGE_NOTICE, CREATE_CONTENT_COMMENT
|
ALL, INDIVIDUAL, CREATE_LIVE, START_LIVE, CANCEL_LIVE, UPLOAD_CONTENT, SEND_MESSAGE, CHANGE_NOTICE,
|
||||||
|
CREATE_CONTENT_COMMENT
|
||||||
}
|
}
|
||||||
|
|
||||||
class FcmEvent(
|
class FcmEvent(
|
||||||
|
@ -131,6 +132,37 @@ class FcmSendListener(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FcmEventType.CANCEL_LIVE -> {
|
||||||
|
if (fcmEvent.roomId != null) {
|
||||||
|
val pushTokenList = memberRepository.getPushTokenFromReservationList(fcmEvent.roomId)
|
||||||
|
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aosPushToken != null) {
|
||||||
|
for (tokens in aosPushToken) {
|
||||||
|
pushService.send(
|
||||||
|
tokens = tokens,
|
||||||
|
title = fcmEvent.title,
|
||||||
|
message = fcmEvent.message,
|
||||||
|
container = "aos"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FcmEventType.UPLOAD_CONTENT -> {
|
FcmEventType.UPLOAD_CONTENT -> {
|
||||||
if (fcmEvent.container.isNotBlank()) {
|
if (fcmEvent.container.isNotBlank()) {
|
||||||
val pushTokens = memberRepository.getUploadContentNotificationRecipientPushTokens(
|
val pushTokens = memberRepository.getUploadContentNotificationRecipientPushTokens(
|
||||||
|
|
|
@ -475,6 +475,15 @@ class LiveRoomService(
|
||||||
}
|
}
|
||||||
|
|
||||||
reservationRepository.cancelReservation(roomId = room.id!!)
|
reservationRepository.cancelReservation(roomId = room.id!!)
|
||||||
|
|
||||||
|
applicationEventPublisher.publishEvent(
|
||||||
|
FcmEvent(
|
||||||
|
type = FcmEventType.CANCEL_LIVE,
|
||||||
|
title = room.member!!.nickname,
|
||||||
|
message = "라이브 취소 : ${room.title}",
|
||||||
|
roomId = request.roomId
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|
|
@ -50,6 +50,7 @@ interface MemberQueryRepository {
|
||||||
fun getMemberByEmail(email: String): Member?
|
fun getMemberByEmail(email: String): Member?
|
||||||
|
|
||||||
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>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
|
@ -255,9 +256,11 @@ class MemberQueryRepositoryImpl(
|
||||||
)
|
)
|
||||||
.from(message)
|
.from(message)
|
||||||
.innerJoin(message.recipient, member)
|
.innerJoin(message.recipient, member)
|
||||||
|
.innerJoin(member.notification, memberNotification)
|
||||||
.where(
|
.where(
|
||||||
message.id.eq(messageId)
|
message.id.eq(messageId)
|
||||||
.and(member.pushToken.isNotNull)
|
.and(member.pushToken.isNotNull)
|
||||||
|
.and(memberNotification.message.isTrue)
|
||||||
)
|
)
|
||||||
.fetchFirst()
|
.fetchFirst()
|
||||||
}
|
}
|
||||||
|
@ -356,4 +359,35 @@ class MemberQueryRepositoryImpl(
|
||||||
|
|
||||||
return mapOf("aos" to aosPushTokens, "ios" to iosPushTokens)
|
return mapOf("aos" to aosPushTokens, "ios" to iosPushTokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getPushTokenFromReservationList(roomId: Long): Map<String, List<List<String>>> {
|
||||||
|
val query = queryFactory
|
||||||
|
.select(liveReservation.member.pushToken)
|
||||||
|
.from(liveReservation)
|
||||||
|
.innerJoin(liveReservation.room, liveRoom)
|
||||||
|
.innerJoin(liveReservation.member, member)
|
||||||
|
|
||||||
|
val where = liveRoom.id.eq(roomId)
|
||||||
|
.and(liveReservation.isActive.isTrue)
|
||||||
|
|
||||||
|
val aosPushTokens = query
|
||||||
|
.where(
|
||||||
|
where
|
||||||
|
.and(member.container.eq("aos"))
|
||||||
|
)
|
||||||
|
.fetch()
|
||||||
|
.toSet()
|
||||||
|
.chunked(500)
|
||||||
|
|
||||||
|
val iosPushTokens = query
|
||||||
|
.where(
|
||||||
|
where
|
||||||
|
.and(member.container.eq("ios"))
|
||||||
|
)
|
||||||
|
.fetch()
|
||||||
|
.toSet()
|
||||||
|
.chunked(500)
|
||||||
|
|
||||||
|
return mapOf("aos" to aosPushTokens, "ios" to iosPushTokens)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue