콘텐츠 댓글의 답글 푸시
- AS-IS : 원 댓글의 글쓴이에게 알림(원 댓글 글쓴이가 답글을 달아도 알림) - To-Be : 답글을 쓴 본인을 제외하고 원 댓글의 답글을 쓴 모든 유저에게 푸시 알림
This commit is contained in:
parent
11bb799bd5
commit
f196b20024
|
@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.content.comment
|
|||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||
import kr.co.vividnext.sodalive.content.comment.QAudioContentComment.audioContentComment
|
||||
import kr.co.vividnext.sodalive.member.QMember.member
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.time.ZoneId
|
||||
|
@ -30,7 +31,11 @@ interface AudioContentCommentQueryRepository {
|
|||
limit: Int
|
||||
): List<GetAudioContentCommentListItem>
|
||||
|
||||
fun findPushTokenByContentCommentId(contentCommentId: Long): FindPushTokenByContentCommentIdResponse?
|
||||
fun findPushTokenByContentIdAndCommentParentIdMyMemberId(
|
||||
contentId: Long,
|
||||
commentParentId: Long?,
|
||||
myMemberId: Long
|
||||
): List<FindPushTokenByContentIdAndCommentParentIdMyMemberIdResponse>
|
||||
}
|
||||
|
||||
@Repository
|
||||
|
@ -143,27 +148,48 @@ class AudioContentCommentQueryRepositoryImpl(
|
|||
.toList()
|
||||
}
|
||||
|
||||
override fun findPushTokenByContentCommentId(contentCommentId: Long): FindPushTokenByContentCommentIdResponse? {
|
||||
val response = queryFactory
|
||||
.selectFrom(audioContentComment)
|
||||
.innerJoin(audioContentComment.audioContent, audioContent)
|
||||
.where(audioContentComment.id.eq(contentCommentId))
|
||||
.fetchFirst()
|
||||
override fun findPushTokenByContentIdAndCommentParentIdMyMemberId(
|
||||
contentId: Long,
|
||||
commentParentId: Long?,
|
||||
myMemberId: Long
|
||||
): List<FindPushTokenByContentIdAndCommentParentIdMyMemberIdResponse> {
|
||||
var where = audioContent.id.eq(contentId)
|
||||
.and(member.id.ne(myMemberId))
|
||||
|
||||
return if (response == null) {
|
||||
null
|
||||
} else {
|
||||
if (response.parent != null) {
|
||||
FindPushTokenByContentCommentIdResponse(
|
||||
pushToken = response.parent!!.member!!.pushToken ?: "",
|
||||
container = response.parent!!.member!!.container
|
||||
)
|
||||
} else {
|
||||
FindPushTokenByContentCommentIdResponse(
|
||||
pushToken = response.audioContent!!.member!!.pushToken ?: "",
|
||||
container = response.audioContent!!.member!!.container
|
||||
)
|
||||
}
|
||||
if (commentParentId != null) {
|
||||
where = where.and(
|
||||
audioContentComment.parent.id.eq(commentParentId)
|
||||
.or(audioContentComment.id.eq(commentParentId))
|
||||
)
|
||||
}
|
||||
|
||||
val response = if (commentParentId != null) {
|
||||
queryFactory
|
||||
.select(
|
||||
QFindPushTokenByContentIdAndCommentParentIdMyMemberIdResponse(
|
||||
member.pushToken.coalesce(""),
|
||||
member.container
|
||||
)
|
||||
)
|
||||
.from(audioContentComment)
|
||||
.innerJoin(audioContentComment.audioContent, audioContent)
|
||||
.innerJoin(audioContentComment.member, member)
|
||||
.where(where)
|
||||
.fetch()
|
||||
} else {
|
||||
queryFactory
|
||||
.select(
|
||||
QFindPushTokenByContentIdAndCommentParentIdMyMemberIdResponse(
|
||||
member.pushToken.coalesce(""),
|
||||
member.container
|
||||
)
|
||||
)
|
||||
.from(audioContent)
|
||||
.innerJoin(audioContent.member, member)
|
||||
.where(where)
|
||||
.fetch()
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,8 @@ class AudioContentCommentService(
|
|||
"콘텐츠에 댓글을 달았습니다.: ${audioContent.title}"
|
||||
},
|
||||
contentId = audioContentId,
|
||||
contentCommentId = audioContentComment.id!!
|
||||
commentParentId = parentId,
|
||||
myMemberId = member.id
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package kr.co.vividnext.sodalive.content.comment
|
||||
|
||||
data class FindPushTokenByContentCommentIdResponse(
|
||||
val pushToken: String,
|
||||
val container: String
|
||||
)
|
|
@ -0,0 +1,8 @@
|
|||
package kr.co.vividnext.sodalive.content.comment
|
||||
|
||||
import com.querydsl.core.annotations.QueryProjection
|
||||
|
||||
data class FindPushTokenByContentIdAndCommentParentIdMyMemberIdResponse @QueryProjection constructor(
|
||||
val pushToken: String,
|
||||
val container: String
|
||||
)
|
|
@ -25,7 +25,8 @@ class FcmEvent(
|
|||
val contentId: Long? = null,
|
||||
val messageId: Long? = null,
|
||||
val creatorId: Long? = null,
|
||||
val contentCommentId: Long? = null
|
||||
val commentParentId: Long? = null,
|
||||
val myMemberId: Long? = null
|
||||
)
|
||||
|
||||
@Component
|
||||
|
@ -228,17 +229,45 @@ class FcmSendListener(
|
|||
}
|
||||
|
||||
FcmEventType.CREATE_CONTENT_COMMENT -> {
|
||||
if (fcmEvent.contentCommentId != null && fcmEvent.contentId != null) {
|
||||
val response = contentCommentRepository.findPushTokenByContentCommentId(
|
||||
contentCommentId = fcmEvent.contentCommentId
|
||||
if (fcmEvent.myMemberId != null && fcmEvent.contentId != null) {
|
||||
val response = contentCommentRepository.findPushTokenByContentIdAndCommentParentIdMyMemberId(
|
||||
contentId = fcmEvent.contentId,
|
||||
commentParentId = fcmEvent.commentParentId,
|
||||
myMemberId = fcmEvent.myMemberId
|
||||
)
|
||||
|
||||
if (response != null) {
|
||||
val iosPushTokens = response
|
||||
.asSequence()
|
||||
.distinct()
|
||||
.filter { it.pushToken.isNotBlank() }
|
||||
.filter { it.container == "ios" }
|
||||
.map { it.pushToken }
|
||||
.toList()
|
||||
|
||||
val aosPushTokens = response
|
||||
.asSequence()
|
||||
.distinct()
|
||||
.filter { it.pushToken.isNotBlank() }
|
||||
.filter { it.container == "aos" }
|
||||
.map { it.pushToken }
|
||||
.toList()
|
||||
|
||||
if (iosPushTokens.isNotEmpty()) {
|
||||
pushService.send(
|
||||
tokens = listOf(response.pushToken),
|
||||
tokens = iosPushTokens,
|
||||
title = fcmEvent.title,
|
||||
message = fcmEvent.message,
|
||||
container = response.container,
|
||||
container = "ios",
|
||||
contentId = fcmEvent.contentId
|
||||
)
|
||||
}
|
||||
|
||||
if (aosPushTokens.isNotEmpty()) {
|
||||
pushService.send(
|
||||
tokens = aosPushTokens,
|
||||
title = fcmEvent.title,
|
||||
message = fcmEvent.message,
|
||||
container = "aos",
|
||||
contentId = fcmEvent.contentId
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue