feat: タイムラインの実装に必要なものを定義

This commit is contained in:
usbharu 2024-07-14 16:35:20 +09:00
parent 0143038707
commit a550ddd5c3
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
3 changed files with 52 additions and 11 deletions

View File

@ -1,9 +1,13 @@
package dev.usbharu.hideout.core.domain.model.filter package dev.usbharu.hideout.core.domain.model.filter
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
interface FilterRepository { interface FilterRepository {
suspend fun save(filter: Filter): Filter suspend fun save(filter: Filter): Filter
suspend fun delete(filter: Filter) suspend fun delete(filter: Filter)
suspend fun findByFilterKeywordId(filterKeywordId: FilterKeywordId): Filter? suspend fun findByFilterKeywordId(filterKeywordId: FilterKeywordId): Filter?
suspend fun findByFilterId(filterId: FilterId): Filter? suspend fun findByFilterId(filterId: FilterId): Filter?
suspend fun findByUserDetailId(userDetailId: UserDetailId): List<Filter>
} }

View File

@ -1,6 +1,10 @@
package dev.usbharu.hideout.core.domain.model.timelinerelationship package dev.usbharu.hideout.core.domain.model.timelinerelationship
import dev.usbharu.hideout.core.domain.model.actor.ActorId
interface TimelineRelationshipRepository { interface TimelineRelationshipRepository {
suspend fun save(timelineRelationship: TimelineRelationship): TimelineRelationship suspend fun save(timelineRelationship: TimelineRelationship): TimelineRelationship
suspend fun delete(timelineRelationship: TimelineRelationship) suspend fun delete(timelineRelationship: TimelineRelationship)
suspend fun findByActorId(actorId: ActorId): List<TimelineRelationship>
} }

View File

@ -1,20 +1,53 @@
package dev.usbharu.hideout.core.infrastructure.timeline 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.relationship.FindRelationshipOption import dev.usbharu.hideout.core.domain.model.filter.Filter
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository import dev.usbharu.hideout.core.domain.model.filter.FilterContext
import dev.usbharu.hideout.core.domain.model.filter.FilterRepository
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.PostRepository
import dev.usbharu.hideout.core.domain.model.timeline.Timeline
import dev.usbharu.hideout.core.domain.model.timeline.TimelineRepository import dev.usbharu.hideout.core.domain.model.timeline.TimelineRepository
import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObject
import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationshipRepository
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
import dev.usbharu.hideout.core.domain.service.filter.FilterDomainService
import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService
import org.springframework.stereotype.Component
@Component
open class DefaultTimelineStore( open class DefaultTimelineStore(
private val timelineRepository: TimelineRepository, private val timelineRepository: TimelineRepository,
private val relationshipRepository: RelationshipRepository private val timelineRelationshipRepository: TimelineRelationshipRepository,
) : AbstractTimelineStore() { private val filterRepository: FilterRepository,
override suspend fun getTimeline(actorId: ActorId): List<ActorId> { private val postRepository: PostRepository,
return relationshipRepository private val filterDomainService: FilterDomainService,
.findByTargetId( idGenerateService: IdGenerateService
actorId, FindRelationshipOption(follow = true, mute = false), ) : AbstractTimelineStore(idGenerateService) {
FindRelationshipOption(block = false) override suspend fun getTimeline(actorId: ActorId): List<Timeline> {
) return timelineRepository.findByIds(
.map { it.actorId } timelineRelationshipRepository
.findByActorId(
actorId
).map { it.timelineId }
)
}
override suspend fun getFilters(userDetailId: UserDetailId): List<Filter> {
return filterRepository.findByUserDetailId(userDetailId)
}
override suspend fun applyFilters(post: Post, filters: List<Filter>): FilteredPost {
return filterDomainService.apply(post, FilterContext.HOME, filters)
}
override suspend fun getPost(postId: PostId): Post? {
return postRepository.findById(postId)
}
override suspend fun insertTimelineObject(timelineObjectList: List<TimelineObject>) {
TODO("Not yet implemented")
} }
} }