diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/timelineobjectdetail/TimelineObjectDetail.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/timelineobjectdetail/TimelineObjectDetail.kt index e5d49aa5..a3039380 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/timelineobjectdetail/TimelineObjectDetail.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/timelineobjectdetail/TimelineObjectDetail.kt @@ -2,6 +2,7 @@ package dev.usbharu.hideout.core.domain.model.support.timelineobjectdetail import dev.usbharu.hideout.core.domain.model.actor.Actor import dev.usbharu.hideout.core.domain.model.post.Post +import dev.usbharu.hideout.core.domain.model.post.PostId import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObject import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObjectId import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObjectWarnFilter @@ -10,6 +11,7 @@ import java.time.Instant data class TimelineObjectDetail( val id: TimelineObjectId, + val postId: PostId, val timelineUserDetail: UserDetail, val post: Post, val postActor: Actor, @@ -36,6 +38,7 @@ data class TimelineObjectDetail( ): TimelineObjectDetail { return TimelineObjectDetail( timelineObject.id, + post.id, timelineUserDetail, post, postActor, diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/timeline/ReadTimelineOption.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/timeline/ReadTimelineOption.kt new file mode 100644 index 00000000..5cee660f --- /dev/null +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/timeline/ReadTimelineOption.kt @@ -0,0 +1,7 @@ +package dev.usbharu.hideout.core.external.timeline + +data class ReadTimelineOption( + val mediaOnly: Boolean = false, + val local: Boolean = false, + val remote: Boolean = false, +) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/timeline/TimelineStore.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/timeline/TimelineStore.kt index 2c9d5296..c7d82556 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/timeline/TimelineStore.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/timeline/TimelineStore.kt @@ -1,6 +1,7 @@ package dev.usbharu.hideout.core.external.timeline import dev.usbharu.hideout.core.domain.model.post.Post +import dev.usbharu.hideout.core.domain.model.support.page.Page import dev.usbharu.hideout.core.domain.model.support.timelineobjectdetail.TimelineObjectDetail import dev.usbharu.hideout.core.domain.model.timeline.Timeline import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationship @@ -16,5 +17,9 @@ interface TimelineStore { suspend fun addTimeline(timeline: Timeline, timelineRelationshipList: List) suspend fun removeTimeline(timeline: Timeline) - suspend fun readTimeline(timeline: Timeline): List + suspend fun readTimeline( + timeline: Timeline, + option: ReadTimelineOption? = null, + page: Page? = null + ): List } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/AbstractTimelineStore.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/AbstractTimelineStore.kt index bd91f5b8..4964c9a9 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/AbstractTimelineStore.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/AbstractTimelineStore.kt @@ -7,6 +7,7 @@ import dev.usbharu.hideout.core.domain.model.filter.FilteredPost import dev.usbharu.hideout.core.domain.model.post.Post import dev.usbharu.hideout.core.domain.model.post.PostId import dev.usbharu.hideout.core.domain.model.post.Visibility +import dev.usbharu.hideout.core.domain.model.support.page.Page import dev.usbharu.hideout.core.domain.model.support.timelineobjectdetail.TimelineObjectDetail import dev.usbharu.hideout.core.domain.model.timeline.Timeline import dev.usbharu.hideout.core.domain.model.timeline.TimelineId @@ -19,6 +20,7 @@ import dev.usbharu.hideout.core.domain.model.timelinerelationship.Visible import dev.usbharu.hideout.core.domain.model.userdetails.UserDetail import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService +import dev.usbharu.hideout.core.external.timeline.ReadTimelineOption import dev.usbharu.hideout.core.external.timeline.TimelineStore import java.time.Instant @@ -104,7 +106,11 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe protected abstract suspend fun getPostsByPostId(postIds: List): List - protected abstract suspend fun getTimelineObject(timelineId: TimelineId): List + protected abstract suspend fun getTimelineObject( + timelineId: TimelineId, + readTimelineOption: ReadTimelineOption?, + page: Page? + ): List override suspend fun updatePost(post: Post) { val timelineObjectByPostId = getTimelineObjectByPostId(post.id) @@ -195,8 +201,12 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe removeTimelineObject(timeline.id) } - override suspend fun readTimeline(timeline: Timeline): List { - val timelineObjectList = getTimelineObject(timeline.id) + override suspend fun readTimeline( + timeline: Timeline, + option: ReadTimelineOption?, + page: Page? + ): List { + val timelineObjectList = getTimelineObject(timeline.id, option, page) val lastUpdatedAt = timelineObjectList.minBy { it.lastUpdatedAt }.lastUpdatedAt val newerFilters = getNewerFilters(timeline.userDetailId, lastUpdatedAt) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/DefaultTimelineStore.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/DefaultTimelineStore.kt index f0015cdf..9b9b9b37 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/DefaultTimelineStore.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/DefaultTimelineStore.kt @@ -24,6 +24,7 @@ import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository import dev.usbharu.hideout.core.domain.service.filter.FilterDomainService import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService +import dev.usbharu.hideout.core.external.timeline.ReadTimelineOption import org.springframework.stereotype.Component import java.time.Instant @@ -101,8 +102,20 @@ open class DefaultTimelineStore( return postRepository.findAllById(postIds) } - override suspend fun getTimelineObject(timelineId: TimelineId): List { - return internalTimelineObjectRepository.findByTimelineId(timelineId) + override suspend fun getTimelineObject( + timelineId: TimelineId, + readTimelineOption: ReadTimelineOption?, + page: Page? + ): List { + return internalTimelineObjectRepository.findByTimelineId( + timelineId, + InternalTimelineObjectOption( + readTimelineOption?.local, + readTimelineOption?.remote, + readTimelineOption?.mediaOnly + ), + page + ) } override suspend fun getActorPost(actorId: ActorId, visibilityList: List): List { diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/InternalTimelineObjectRepository.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/InternalTimelineObjectRepository.kt index 71e5a71c..23804c04 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/InternalTimelineObjectRepository.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/InternalTimelineObjectRepository.kt @@ -2,6 +2,7 @@ package dev.usbharu.hideout.core.infrastructure.timeline import dev.usbharu.hideout.core.domain.model.actor.ActorId import dev.usbharu.hideout.core.domain.model.post.PostId +import dev.usbharu.hideout.core.domain.model.support.page.Page import dev.usbharu.hideout.core.domain.model.timeline.TimelineId import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObject @@ -17,5 +18,15 @@ interface InternalTimelineObjectRepository { suspend fun deleteByTimelineIdAndActorId(timelineId: TimelineId, actorId: ActorId) suspend fun deleteByTimelineId(timelineId: TimelineId) - suspend fun findByTimelineId(timelineId: TimelineId): List + suspend fun findByTimelineId( + timelineId: TimelineId, + internalTimelineObjectOption: InternalTimelineObjectOption? = null, + page: Page? = null + ): List } + +data class InternalTimelineObjectOption( + val localOnly: Boolean? = null, + val remoteOnly: Boolean? = null, + val mediaOnly: Boolean? = null +) \ No newline at end of file