commit
56f7b6c449
|
@ -65,7 +65,7 @@ class FcmSendListener(
|
|||
tokens = tokens,
|
||||
title = fcmEvent.title,
|
||||
message = fcmEvent.message,
|
||||
container = fcmEvent.container
|
||||
container = "ios"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -76,14 +76,34 @@ class FcmSendListener(
|
|||
tokens = tokens,
|
||||
title = fcmEvent.title,
|
||||
message = fcmEvent.message,
|
||||
container = fcmEvent.container
|
||||
container = "aos"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FcmEventType.CREATE_LIVE, FcmEventType.START_LIVE -> {
|
||||
FcmEventType.CREATE_LIVE -> {
|
||||
if (fcmEvent.container.isNotBlank()) {
|
||||
val pushTokens = memberRepository.getCreateLiveRoomNotificationRecipientPushTokens(
|
||||
creatorId = fcmEvent.creatorId!!,
|
||||
isAuth = fcmEvent.isAuth,
|
||||
container = fcmEvent.container
|
||||
)
|
||||
|
||||
for (tokens in pushTokens) {
|
||||
pushService.send(
|
||||
tokens = tokens,
|
||||
title = fcmEvent.title,
|
||||
message = fcmEvent.message,
|
||||
container = fcmEvent.container,
|
||||
roomId = fcmEvent.roomId
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FcmEventType.START_LIVE -> {
|
||||
if (fcmEvent.container.isNotBlank()) {
|
||||
val pushTokens = memberRepository.getCreateLiveRoomNotificationRecipientPushTokens(
|
||||
creatorId = fcmEvent.creatorId!!,
|
||||
|
|
|
@ -3,11 +3,14 @@ package kr.co.vividnext.sodalive.fcm
|
|||
import com.google.firebase.messaging.FirebaseMessaging
|
||||
import com.google.firebase.messaging.MulticastMessage
|
||||
import com.google.firebase.messaging.Notification
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.scheduling.annotation.Async
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
class FcmService {
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
@Async
|
||||
fun send(
|
||||
tokens: List<String>,
|
||||
|
@ -18,35 +21,40 @@ class FcmService {
|
|||
messageId: Long? = null,
|
||||
contentId: Long? = null
|
||||
) {
|
||||
val multicastMessage = MulticastMessage.builder()
|
||||
.addAllTokens(tokens)
|
||||
if (tokens.isNotEmpty()) {
|
||||
logger.info("os: $container")
|
||||
val multicastMessage = MulticastMessage.builder()
|
||||
.addAllTokens(tokens)
|
||||
|
||||
if (container == "ios") {
|
||||
multicastMessage
|
||||
.setNotification(
|
||||
Notification.builder()
|
||||
.setTitle(title)
|
||||
.setBody(message)
|
||||
.build()
|
||||
)
|
||||
} else {
|
||||
multicastMessage
|
||||
.putData("title", title)
|
||||
.putData("message", message)
|
||||
if (container == "ios") {
|
||||
multicastMessage
|
||||
.setNotification(
|
||||
Notification.builder()
|
||||
.setTitle(title)
|
||||
.setBody(message)
|
||||
.build()
|
||||
)
|
||||
} else {
|
||||
multicastMessage
|
||||
.putData("title", title)
|
||||
.putData("message", message)
|
||||
}
|
||||
|
||||
if (roomId != null) {
|
||||
multicastMessage.putData("room_id", roomId.toString())
|
||||
}
|
||||
|
||||
if (messageId != null) {
|
||||
multicastMessage.putData("message_id", messageId.toString())
|
||||
}
|
||||
|
||||
if (contentId != null) {
|
||||
multicastMessage.putData("content_id", contentId.toString())
|
||||
}
|
||||
|
||||
val response = FirebaseMessaging.getInstance().sendEachForMulticast(multicastMessage.build())
|
||||
logger.info("보내기 성공: ${response.successCount}")
|
||||
logger.info("보내기 실패: ${response.failureCount}")
|
||||
}
|
||||
|
||||
if (roomId != null) {
|
||||
multicastMessage.putData("room_id", roomId.toString())
|
||||
}
|
||||
|
||||
if (messageId != null) {
|
||||
multicastMessage.putData("message_id", messageId.toString())
|
||||
}
|
||||
|
||||
if (contentId != null) {
|
||||
multicastMessage.putData("content_id", contentId.toString())
|
||||
}
|
||||
|
||||
FirebaseMessaging.getInstance().sendEachForMulticast(multicastMessage.build())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -301,6 +301,7 @@ class LiveRoomService(
|
|||
channelName = room.channelName,
|
||||
beginDateTime = beginDateTime.format(DateTimeFormatter.ofPattern("yyyy.MM.dd E hh:mm a")),
|
||||
isPaid = false,
|
||||
isAdult = room.isAdult,
|
||||
isPrivateRoom = room.type == LiveRoomType.PRIVATE,
|
||||
password = room.password
|
||||
)
|
||||
|
|
|
@ -9,6 +9,7 @@ data class GetRoomDetailResponse(
|
|||
val title: String,
|
||||
val notice: String,
|
||||
var isPaid: Boolean,
|
||||
val isAdult: Boolean,
|
||||
val isPrivateRoom: Boolean,
|
||||
val password: String?,
|
||||
val tags: List<String>,
|
||||
|
|
|
@ -80,6 +80,7 @@ class MemberQueryRepositoryImpl(
|
|||
var where = member.isActive.isTrue
|
||||
.and(member.email.notIn("admin@sodalive.net"))
|
||||
.and(member.container.eq(container))
|
||||
.and(member.pushToken.isNotNull)
|
||||
|
||||
if (isAuth) {
|
||||
where = where.and(member.auth.isNotNull)
|
||||
|
@ -113,6 +114,7 @@ class MemberQueryRepositoryImpl(
|
|||
blockMemberRepository.getBlockedMemberList(creatorId)
|
||||
)
|
||||
)
|
||||
.and(creatorFollowing.member.pushToken.isNotNull)
|
||||
|
||||
if (isAuth) {
|
||||
where = where.and(member.auth.isNotNull)
|
||||
|
@ -149,6 +151,7 @@ class MemberQueryRepositoryImpl(
|
|||
blockMemberRepository.getBlockedMemberList(creatorId)
|
||||
)
|
||||
)
|
||||
.and(creatorFollowing.member.pushToken.isNotNull)
|
||||
|
||||
if (isAuth) {
|
||||
where = where.and(member.auth.isNotNull)
|
||||
|
@ -177,7 +180,10 @@ class MemberQueryRepositoryImpl(
|
|||
)
|
||||
.from(message)
|
||||
.innerJoin(message.recipient, member)
|
||||
.where(message.id.eq(messageId))
|
||||
.where(
|
||||
message.id.eq(messageId)
|
||||
.and(member.pushToken.isNotNull)
|
||||
)
|
||||
.fetchFirst()
|
||||
}
|
||||
|
||||
|
@ -188,6 +194,7 @@ class MemberQueryRepositoryImpl(
|
|||
var where = member.isActive.isTrue
|
||||
.and(member.email.notIn("admin@sodalive.net"))
|
||||
.and(member.id.`in`(*recipients.toTypedArray()))
|
||||
.and(member.pushToken.isNotNull)
|
||||
|
||||
if (isAuth) {
|
||||
where = where.and(member.auth.isNotNull)
|
||||
|
|
Loading…
Reference in New Issue