This commit is contained in:
usbharu 2024-07-29 00:15:40 +09:00
parent e728b0f990
commit e70f104b5c
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
6 changed files with 56 additions and 7 deletions

View File

@ -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.actor.Actor
import dev.usbharu.hideout.core.domain.model.post.Post 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.TimelineObject
import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObjectId import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObjectId
import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObjectWarnFilter import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObjectWarnFilter
@ -10,6 +11,7 @@ import java.time.Instant
data class TimelineObjectDetail( data class TimelineObjectDetail(
val id: TimelineObjectId, val id: TimelineObjectId,
val postId: PostId,
val timelineUserDetail: UserDetail, val timelineUserDetail: UserDetail,
val post: Post, val post: Post,
val postActor: Actor, val postActor: Actor,
@ -36,6 +38,7 @@ data class TimelineObjectDetail(
): TimelineObjectDetail { ): TimelineObjectDetail {
return TimelineObjectDetail( return TimelineObjectDetail(
timelineObject.id, timelineObject.id,
post.id,
timelineUserDetail, timelineUserDetail,
post, post,
postActor, postActor,

View File

@ -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,
)

View File

@ -1,6 +1,7 @@
package dev.usbharu.hideout.core.external.timeline package dev.usbharu.hideout.core.external.timeline
import dev.usbharu.hideout.core.domain.model.post.Post 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.support.timelineobjectdetail.TimelineObjectDetail
import dev.usbharu.hideout.core.domain.model.timeline.Timeline import dev.usbharu.hideout.core.domain.model.timeline.Timeline
import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationship import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationship
@ -16,5 +17,9 @@ interface TimelineStore {
suspend fun addTimeline(timeline: Timeline, timelineRelationshipList: List<TimelineRelationship>) suspend fun addTimeline(timeline: Timeline, timelineRelationshipList: List<TimelineRelationship>)
suspend fun removeTimeline(timeline: Timeline) suspend fun removeTimeline(timeline: Timeline)
suspend fun readTimeline(timeline: Timeline): List<TimelineObjectDetail> suspend fun readTimeline(
timeline: Timeline,
option: ReadTimelineOption? = null,
page: Page? = null
): List<TimelineObjectDetail>
} }

View File

@ -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.Post
import dev.usbharu.hideout.core.domain.model.post.PostId 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.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.support.timelineobjectdetail.TimelineObjectDetail
import dev.usbharu.hideout.core.domain.model.timeline.Timeline import dev.usbharu.hideout.core.domain.model.timeline.Timeline
import dev.usbharu.hideout.core.domain.model.timeline.TimelineId 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.UserDetail
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService 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 dev.usbharu.hideout.core.external.timeline.TimelineStore
import java.time.Instant import java.time.Instant
@ -104,7 +106,11 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
protected abstract suspend fun getPostsByPostId(postIds: List<PostId>): List<Post> protected abstract suspend fun getPostsByPostId(postIds: List<PostId>): List<Post>
protected abstract suspend fun getTimelineObject(timelineId: TimelineId): List<TimelineObject> protected abstract suspend fun getTimelineObject(
timelineId: TimelineId,
readTimelineOption: ReadTimelineOption?,
page: Page?
): List<TimelineObject>
override suspend fun updatePost(post: Post) { override suspend fun updatePost(post: Post) {
val timelineObjectByPostId = getTimelineObjectByPostId(post.id) val timelineObjectByPostId = getTimelineObjectByPostId(post.id)
@ -195,8 +201,12 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
removeTimelineObject(timeline.id) removeTimelineObject(timeline.id)
} }
override suspend fun readTimeline(timeline: Timeline): List<TimelineObjectDetail> { override suspend fun readTimeline(
val timelineObjectList = getTimelineObject(timeline.id) timeline: Timeline,
option: ReadTimelineOption?,
page: Page?
): List<TimelineObjectDetail> {
val timelineObjectList = getTimelineObject(timeline.id, option, page)
val lastUpdatedAt = timelineObjectList.minBy { it.lastUpdatedAt }.lastUpdatedAt val lastUpdatedAt = timelineObjectList.minBy { it.lastUpdatedAt }.lastUpdatedAt
val newerFilters = getNewerFilters(timeline.userDetailId, lastUpdatedAt) val newerFilters = getNewerFilters(timeline.userDetailId, lastUpdatedAt)

View File

@ -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.model.userdetails.UserDetailRepository
import dev.usbharu.hideout.core.domain.service.filter.FilterDomainService import dev.usbharu.hideout.core.domain.service.filter.FilterDomainService
import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService
import dev.usbharu.hideout.core.external.timeline.ReadTimelineOption
import org.springframework.stereotype.Component import org.springframework.stereotype.Component
import java.time.Instant import java.time.Instant
@ -101,8 +102,20 @@ open class DefaultTimelineStore(
return postRepository.findAllById(postIds) return postRepository.findAllById(postIds)
} }
override suspend fun getTimelineObject(timelineId: TimelineId): List<TimelineObject> { override suspend fun getTimelineObject(
return internalTimelineObjectRepository.findByTimelineId(timelineId) timelineId: TimelineId,
readTimelineOption: ReadTimelineOption?,
page: Page?
): List<TimelineObject> {
return internalTimelineObjectRepository.findByTimelineId(
timelineId,
InternalTimelineObjectOption(
readTimelineOption?.local,
readTimelineOption?.remote,
readTimelineOption?.mediaOnly
),
page
)
} }
override suspend fun getActorPost(actorId: ActorId, visibilityList: List<Visibility>): List<Post> { override suspend fun getActorPost(actorId: ActorId, visibilityList: List<Visibility>): List<Post> {

View File

@ -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.actor.ActorId
import dev.usbharu.hideout.core.domain.model.post.PostId 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.timeline.TimelineId
import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObject import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObject
@ -17,5 +18,15 @@ interface InternalTimelineObjectRepository {
suspend fun deleteByTimelineIdAndActorId(timelineId: TimelineId, actorId: ActorId) suspend fun deleteByTimelineIdAndActorId(timelineId: TimelineId, actorId: ActorId)
suspend fun deleteByTimelineId(timelineId: TimelineId) suspend fun deleteByTimelineId(timelineId: TimelineId)
suspend fun findByTimelineId(timelineId: TimelineId): List<TimelineObject> suspend fun findByTimelineId(
timelineId: TimelineId,
internalTimelineObjectOption: InternalTimelineObjectOption? = null,
page: Page? = null
): List<TimelineObject>
} }
data class InternalTimelineObjectOption(
val localOnly: Boolean? = null,
val remoteOnly: Boolean? = null,
val mediaOnly: Boolean? = null
)