diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/domain/CreatorChannelHome.kt b/src/main/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/domain/CreatorChannelHome.kt index 2dfeb8c3..8753ecb0 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/domain/CreatorChannelHome.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/domain/CreatorChannelHome.kt @@ -68,7 +68,8 @@ data class CreatorChannelSchedule( val scheduledAt: LocalDateTime, val title: String, val type: CreatorActivityType, - val targetId: Long + val targetId: Long, + val isAdult: Boolean ) data class CreatorChannelSeries( diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/domain/CreatorChannelHomeQueryPolicy.kt b/src/main/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/domain/CreatorChannelHomeQueryPolicy.kt index dde7d19d..862aa3f7 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/domain/CreatorChannelHomeQueryPolicy.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/domain/CreatorChannelHomeQueryPolicy.kt @@ -6,10 +6,12 @@ import java.time.LocalDateTime class CreatorChannelHomeQueryPolicy { fun limitSchedules( schedules: List, - now: LocalDateTime + now: LocalDateTime, + canViewAdultContent: Boolean ): List { return schedules .filter { it.scheduledAt > now } + .filter { canViewAdultContent || !it.isAdult } .sortedWith(compareBy { it.scheduledAt }.thenBy { it.type.scheduleOrder() }) .take(3) } diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/application/CreatorChannelHomeQueryServiceTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/application/CreatorChannelHomeQueryServiceTest.kt index 0427524e..bd503dea 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/application/CreatorChannelHomeQueryServiceTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/application/CreatorChannelHomeQueryServiceTest.kt @@ -165,7 +165,8 @@ class CreatorChannelHomeQueryServiceTest { scheduledAt = LocalDateTime.of(2026, 6, 12, 3, 0), title = "schedule", type = CreatorActivityType.LIVE, - targetId = 501L + targetId = 501L, + isAdult = false ) ), audioContents = listOf( diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/domain/CreatorChannelHomeQueryPolicyTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/domain/CreatorChannelHomeQueryPolicyTest.kt index c15d651f..5bbdced7 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/domain/CreatorChannelHomeQueryPolicyTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/domain/CreatorChannelHomeQueryPolicyTest.kt @@ -22,7 +22,7 @@ class CreatorChannelHomeQueryPolicyTest { schedule(targetId = 3L, scheduledAt = LocalDateTime.of(2026, 6, 12, 12, 0)) ) - val limited = policy.limitSchedules(schedules, now) + val limited = policy.limitSchedules(schedules, now, canViewAdultContent = true) assertEquals(listOf(1L, 2L, 3L), limited.map { it.targetId }) } @@ -37,7 +37,7 @@ class CreatorChannelHomeQueryPolicyTest { schedule(targetId = 3L, scheduledAt = now.plusMinutes(1)) ) - val limited = policy.limitSchedules(schedules, now) + val limited = policy.limitSchedules(schedules, now, canViewAdultContent = true) assertEquals(listOf(3L), limited.map { it.targetId }) } @@ -51,11 +51,25 @@ class CreatorChannelHomeQueryPolicyTest { schedule(targetId = 1L, scheduledAt = scheduledAt, type = CreatorActivityType.LIVE) ) - val limited = policy.limitSchedules(schedules, scheduledAt.minusMinutes(1)) + val limited = policy.limitSchedules(schedules, scheduledAt.minusMinutes(1), canViewAdultContent = true) assertEquals(listOf(CreatorActivityType.LIVE, CreatorActivityType.AUDIO), limited.map { it.type }) } + @Test + @DisplayName("조회자의 성인 노출 정책이 false이면 성인 스케줄을 제외한다") + fun shouldExcludeAdultSchedulesWhenViewerCannotViewAdultContent() { + val now = LocalDateTime.of(2026, 6, 12, 9, 0) + val schedules = listOf( + schedule(targetId = 1L, scheduledAt = now.plusMinutes(1), isAdult = true), + schedule(targetId = 2L, scheduledAt = now.plusMinutes(2), isAdult = false) + ) + + val limited = policy.limitSchedules(schedules, now, canViewAdultContent = false) + + assertEquals(listOf(2L), limited.map { it.targetId }) + } + @Test @DisplayName("오디오 목록에서는 latestAudioContentId와 같은 콘텐츠를 제외한다") fun shouldExcludeLatestAudioContent() { @@ -86,13 +100,15 @@ class CreatorChannelHomeQueryPolicyTest { private fun schedule( targetId: Long, scheduledAt: LocalDateTime, - type: CreatorActivityType = CreatorActivityType.LIVE + type: CreatorActivityType = CreatorActivityType.LIVE, + isAdult: Boolean = false ): CreatorChannelSchedule { return CreatorChannelSchedule( scheduledAt = scheduledAt, title = "schedule-$targetId", type = type, - targetId = targetId + targetId = targetId, + isAdult = isAdult ) }