차단유저 필터링 로직 추가

This commit is contained in:
Klaus 2023-08-09 06:54:25 +09:00
parent 705bf0b6b2
commit e9723d37ba
3 changed files with 29 additions and 7 deletions

View File

@ -44,6 +44,7 @@ class LiveRecommendRepository(
fun getOnAirRecommendChannelList( fun getOnAirRecommendChannelList(
memberId: Long, memberId: Long,
isBlocked: (Long) -> Boolean,
isAdult: Boolean isAdult: Boolean
): List<GetRecommendChannelResponse> { ): List<GetRecommendChannelResponse> {
var where = member.role.eq(MemberRole.CREATOR) var where = member.role.eq(MemberRole.CREATOR)
@ -75,12 +76,16 @@ class LiveRecommendRepository(
.orderBy(Expressions.numberTemplate(Double::class.java, "function('rand')").asc()) .orderBy(Expressions.numberTemplate(Double::class.java, "function('rand')").asc())
.limit(20) .limit(20)
.fetch() .fetch()
.asSequence()
.filter { !isBlocked(it.creatorId) }
.toList()
} }
fun getRecommendChannelList( fun getRecommendChannelList(
memberId: Long, memberId: Long,
withOutCreatorList: List<Long>, withOutCreatorList: List<Long>,
limit: Long limit: Long,
isBlocked: (Long) -> Boolean
): List<GetRecommendChannelResponse> { ): List<GetRecommendChannelResponse> {
val where = member.role.eq(MemberRole.CREATOR) val where = member.role.eq(MemberRole.CREATOR)
.and(member.isActive.isTrue) .and(member.isActive.isTrue)

View File

@ -1,10 +1,14 @@
package kr.co.vividnext.sodalive.live.recommend package kr.co.vividnext.sodalive.live.recommend
import kr.co.vividnext.sodalive.member.Member import kr.co.vividnext.sodalive.member.Member
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
@Service @Service
class LiveRecommendService(private val repository: LiveRecommendRepository) { class LiveRecommendService(
private val repository: LiveRecommendRepository,
private val blockMemberRepository: BlockMemberRepository
) {
fun getRecommendLive(member: Member): List<GetRecommendLiveResponse> { fun getRecommendLive(member: Member): List<GetRecommendLiveResponse> {
return repository.getRecommendLive( return repository.getRecommendLive(
@ -14,7 +18,11 @@ class LiveRecommendService(private val repository: LiveRecommendRepository) {
} }
fun getRecommendChannelList(member: Member): List<GetRecommendChannelResponse> { fun getRecommendChannelList(member: Member): List<GetRecommendChannelResponse> {
val onAirChannelList = repository.getOnAirRecommendChannelList(member.id!!, isAdult = member.auth != null) val onAirChannelList = repository.getOnAirRecommendChannelList(
member.id!!,
isBlocked = { blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it) },
isAdult = member.auth != null
)
if (onAirChannelList.size >= 20) { if (onAirChannelList.size >= 20) {
return onAirChannelList return onAirChannelList
@ -27,7 +35,8 @@ class LiveRecommendService(private val repository: LiveRecommendRepository) {
val notOnAirCreatorList = repository.getRecommendChannelList( val notOnAirCreatorList = repository.getRecommendChannelList(
member.id!!, member.id!!,
withOutCreatorList = onAirCreatorIdList, withOutCreatorList = onAirCreatorIdList,
limit = (20 - onAirChannelList.size).toLong() limit = (20 - onAirChannelList.size).toLong(),
isBlocked = { blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it) }
) )
return onAirChannelList + notOnAirCreatorList return onAirChannelList + notOnAirCreatorList

View File

@ -115,9 +115,13 @@ class LiveRoomService(
isAdult = member.auth != null isAdult = member.auth != null
) )
.asSequence() .asSequence()
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!) }
.map { .map {
val roomInfo = roomInfoRepository.findByIdOrNull(it.id!!) val roomInfo = roomInfoRepository.findByIdOrNull(it.id!!)
val reservations = it.reservations
.filter { reservation -> reservation.member!!.id!! == member.id!! && reservation.isActive }
val beginDateTime = it.beginDateTime val beginDateTime = it.beginDateTime
.atZone(ZoneId.of("UTC")) .atZone(ZoneId.of("UTC"))
.withZoneSameInstant(ZoneId.of(timezone)) .withZoneSameInstant(ZoneId.of(timezone))
@ -138,13 +142,17 @@ class LiveRoomService(
channelName = it.channelName, channelName = it.channelName,
managerNickname = it.member!!.nickname, managerNickname = it.member!!.nickname,
managerId = it.member!!.id!!, managerId = it.member!!.id!!,
tags = listOf(), tags = it.tags
.asSequence()
.filter { tag -> tag.tag.isActive }
.map { tag -> tag.tag.tag }
.toList(),
coverImageUrl = if (it.coverImage!!.startsWith("https://")) { coverImageUrl = if (it.coverImage!!.startsWith("https://")) {
it.coverImage!! it.coverImage!!
} else { } else {
"$cloudFrontHost/${it.coverImage!!}" "$cloudFrontHost/${it.coverImage!!}"
}, },
isReservation = false, isReservation = reservations.isNotEmpty(),
isPrivateRoom = it.type == LiveRoomType.PRIVATE isPrivateRoom = it.type == LiveRoomType.PRIVATE
) )
} }
@ -742,7 +750,7 @@ class LiveRoomService(
isSpeaker = isSpeaker, isSpeaker = isSpeaker,
isManager = isManager, isManager = isManager,
isFollowing = isFollowing, isFollowing = isFollowing,
isBlock = false isBlock = blockMemberRepository.isBlocked(blockedMemberId = userResponse.id, memberId = memberResponse.id)
) )
} }