Compare commits
No commits in common. "60257c4ef4378e460c0273bda9d8c0e7834bacd1" and "1e0b79bf62474e4511138115003e0ba0b07d3125" have entirely different histories.
60257c4ef4
...
1e0b79bf62
|
@ -1,7 +1,6 @@
|
||||||
package kr.co.vividnext.sodalive.content.comment
|
package kr.co.vividnext.sodalive.content.comment
|
||||||
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
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.content.comment.QAudioContentComment.audioContentComment
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
@ -29,8 +28,6 @@ interface AudioContentCommentQueryRepository {
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Int
|
limit: Int
|
||||||
): List<GetAudioContentCommentListItem>
|
): List<GetAudioContentCommentListItem>
|
||||||
|
|
||||||
fun findPushTokenByContentCommentId(contentCommentId: Long): FindPushTokenByContentCommentIdResponse?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
|
@ -141,28 +138,4 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||||
}
|
}
|
||||||
.toList()
|
.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun findPushTokenByContentCommentId(contentCommentId: Long): FindPushTokenByContentCommentIdResponse? {
|
|
||||||
val response = queryFactory
|
|
||||||
.selectFrom(audioContentComment)
|
|
||||||
.innerJoin(audioContentComment.audioContent, audioContent)
|
|
||||||
.where(audioContentComment.id.eq(contentCommentId))
|
|
||||||
.fetchFirst()
|
|
||||||
|
|
||||||
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
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,8 @@ package kr.co.vividnext.sodalive.content.comment
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import kr.co.vividnext.sodalive.content.AudioContentRepository
|
import kr.co.vividnext.sodalive.content.AudioContentRepository
|
||||||
import kr.co.vividnext.sodalive.fcm.FcmEvent
|
|
||||||
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
import org.springframework.beans.factory.annotation.Value
|
import org.springframework.beans.factory.annotation.Value
|
||||||
import org.springframework.context.ApplicationEventPublisher
|
|
||||||
import org.springframework.data.domain.Pageable
|
import org.springframework.data.domain.Pageable
|
||||||
import org.springframework.data.repository.findByIdOrNull
|
import org.springframework.data.repository.findByIdOrNull
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -17,7 +14,6 @@ import org.springframework.transaction.annotation.Transactional
|
||||||
class AudioContentCommentService(
|
class AudioContentCommentService(
|
||||||
private val repository: AudioContentCommentRepository,
|
private val repository: AudioContentCommentRepository,
|
||||||
private val audioContentRepository: AudioContentRepository,
|
private val audioContentRepository: AudioContentRepository,
|
||||||
private val applicationEventPublisher: ApplicationEventPublisher,
|
|
||||||
|
|
||||||
@Value("\${cloud.aws.cloud-front.host}")
|
@Value("\${cloud.aws.cloud-front.host}")
|
||||||
private val cloudFrontHost: String
|
private val cloudFrontHost: String
|
||||||
|
@ -42,24 +38,6 @@ class AudioContentCommentService(
|
||||||
}
|
}
|
||||||
|
|
||||||
repository.save(audioContentComment)
|
repository.save(audioContentComment)
|
||||||
|
|
||||||
applicationEventPublisher.publishEvent(
|
|
||||||
FcmEvent(
|
|
||||||
type = FcmEventType.CREATE_CONTENT_COMMENT,
|
|
||||||
title = if (parent != null) {
|
|
||||||
parent.member!!.nickname
|
|
||||||
} else {
|
|
||||||
member.nickname
|
|
||||||
},
|
|
||||||
message = if (parent != null) {
|
|
||||||
"댓글에 답글을 달았습니다.: ${audioContent.title}"
|
|
||||||
} else {
|
|
||||||
"콘텐츠에 댓글을 달았습니다.: ${audioContent.title}"
|
|
||||||
},
|
|
||||||
contentId = audioContentId,
|
|
||||||
contentCommentId = audioContentComment.id!!
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.content.comment
|
|
||||||
|
|
||||||
data class FindPushTokenByContentCommentIdResponse(
|
|
||||||
val pushToken: String,
|
|
||||||
val container: String
|
|
||||||
)
|
|
|
@ -1,15 +1,12 @@
|
||||||
package kr.co.vividnext.sodalive.fcm
|
package kr.co.vividnext.sodalive.fcm
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.content.comment.AudioContentCommentRepository
|
|
||||||
import kr.co.vividnext.sodalive.member.MemberRepository
|
import kr.co.vividnext.sodalive.member.MemberRepository
|
||||||
|
import org.springframework.context.event.EventListener
|
||||||
import org.springframework.scheduling.annotation.Async
|
import org.springframework.scheduling.annotation.Async
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
import org.springframework.transaction.annotation.Propagation
|
|
||||||
import org.springframework.transaction.annotation.Transactional
|
|
||||||
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, UPLOAD_CONTENT, SEND_MESSAGE, CHANGE_NOTICE
|
||||||
}
|
}
|
||||||
|
|
||||||
class FcmEvent(
|
class FcmEvent(
|
||||||
|
@ -22,19 +19,16 @@ class FcmEvent(
|
||||||
val roomId: Long? = null,
|
val roomId: Long? = null,
|
||||||
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 contentCommentId: Long? = null
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
class FcmSendListener(
|
class FcmSendListener(
|
||||||
private val pushService: FcmService,
|
private val pushService: FcmService,
|
||||||
private val memberRepository: MemberRepository,
|
private val memberRepository: MemberRepository
|
||||||
private val contentCommentRepository: AudioContentCommentRepository
|
|
||||||
) {
|
) {
|
||||||
@Async
|
@Async
|
||||||
@TransactionalEventListener
|
@EventListener
|
||||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
||||||
fun send(fcmEvent: FcmEvent) {
|
fun send(fcmEvent: FcmEvent) {
|
||||||
when (fcmEvent.type) {
|
when (fcmEvent.type) {
|
||||||
FcmEventType.ALL -> {
|
FcmEventType.ALL -> {
|
||||||
|
@ -195,24 +189,6 @@ class FcmSendListener(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FcmEventType.CREATE_CONTENT_COMMENT -> {
|
|
||||||
if (fcmEvent.contentCommentId != null && fcmEvent.contentId != null) {
|
|
||||||
val response = contentCommentRepository.findPushTokenByContentCommentId(
|
|
||||||
contentCommentId = fcmEvent.contentCommentId
|
|
||||||
)
|
|
||||||
|
|
||||||
if (response != null) {
|
|
||||||
pushService.send(
|
|
||||||
tokens = listOf(response.pushToken),
|
|
||||||
title = fcmEvent.title,
|
|
||||||
message = fcmEvent.message,
|
|
||||||
container = response.container,
|
|
||||||
contentId = fcmEvent.contentId
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue