Compare commits

..

No commits in common. "858ce524f961654f945ea87ce32cfcbcc615800c" and "3795fb4a403af2317f61dee1db95a6e2a87ee0dd" have entirely different histories.

5 changed files with 33 additions and 92 deletions

View File

@ -3,7 +3,6 @@ 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
@ -31,11 +30,7 @@ interface AudioContentCommentQueryRepository {
limit: Int
): List<GetAudioContentCommentListItem>
fun findPushTokenByContentIdAndCommentParentIdMyMemberId(
contentId: Long,
commentParentId: Long?,
myMemberId: Long
): List<FindPushTokenByContentIdAndCommentParentIdMyMemberIdResponse>
fun findPushTokenByContentCommentId(contentCommentId: Long): FindPushTokenByContentCommentIdResponse?
}
@Repository
@ -148,49 +143,27 @@ class AudioContentCommentQueryRepositoryImpl(
.toList()
}
override fun findPushTokenByContentIdAndCommentParentIdMyMemberId(
contentId: Long,
commentParentId: Long?,
myMemberId: Long
): List<FindPushTokenByContentIdAndCommentParentIdMyMemberIdResponse> {
var where = audioContent.id.eq(contentId)
.and(member.id.ne(myMemberId))
.and(audioContentComment.isActive.isTrue)
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)
override fun findPushTokenByContentCommentId(contentCommentId: Long): FindPushTokenByContentCommentIdResponse? {
val response = queryFactory
.selectFrom(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()
}
.where(audioContentComment.id.eq(contentCommentId))
.fetchFirst()
return response
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
)
}
}
}
}

View File

@ -57,8 +57,7 @@ class AudioContentCommentService(
"콘텐츠에 댓글을 달았습니다.: ${audioContent.title}"
},
contentId = audioContentId,
commentParentId = parentId,
myMemberId = member.id
contentCommentId = audioContentComment.id!!
)
)
}

View File

@ -0,0 +1,6 @@
package kr.co.vividnext.sodalive.content.comment
data class FindPushTokenByContentCommentIdResponse(
val pushToken: String,
val container: String
)

View File

@ -1,8 +0,0 @@
package kr.co.vividnext.sodalive.content.comment
import com.querydsl.core.annotations.QueryProjection
data class FindPushTokenByContentIdAndCommentParentIdMyMemberIdResponse @QueryProjection constructor(
val pushToken: String,
val container: String
)

View File

@ -25,8 +25,7 @@ class FcmEvent(
val contentId: Long? = null,
val messageId: Long? = null,
val creatorId: Long? = null,
val commentParentId: Long? = null,
val myMemberId: Long? = null
val contentCommentId: Long? = null
)
@Component
@ -229,45 +228,17 @@ class FcmSendListener(
}
FcmEventType.CREATE_CONTENT_COMMENT -> {
if (fcmEvent.myMemberId != null && fcmEvent.contentId != null) {
val response = contentCommentRepository.findPushTokenByContentIdAndCommentParentIdMyMemberId(
contentId = fcmEvent.contentId,
commentParentId = fcmEvent.commentParentId,
myMemberId = fcmEvent.myMemberId
if (fcmEvent.contentCommentId != null && fcmEvent.contentId != null) {
val response = contentCommentRepository.findPushTokenByContentCommentId(
contentCommentId = fcmEvent.contentCommentId
)
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()) {
if (response != null) {
pushService.send(
tokens = iosPushTokens,
tokens = listOf(response.pushToken),
title = fcmEvent.title,
message = fcmEvent.message,
container = "ios",
contentId = fcmEvent.contentId
)
}
if (aosPushTokens.isNotEmpty()) {
pushService.send(
tokens = aosPushTokens,
title = fcmEvent.title,
message = fcmEvent.message,
container = "aos",
container = response.container,
contentId = fcmEvent.contentId
)
}