mirror of https://github.com/usbharu/Hideout.git
feat: Timelineの構築に必要なものを追加
This commit is contained in:
parent
ed872610f7
commit
faee779cfb
|
@ -21,7 +21,7 @@ import dev.usbharu.hideout.core.domain.event.actor.ActorEvent.*
|
|||
import dev.usbharu.hideout.core.domain.model.emoji.EmojiId
|
||||
import dev.usbharu.hideout.core.domain.model.instance.InstanceId
|
||||
import dev.usbharu.hideout.core.domain.model.media.MediaId
|
||||
import dev.usbharu.hideout.core.domain.model.shared.Domain
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.Domain
|
||||
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable
|
||||
import java.net.URI
|
||||
import java.time.Instant
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package dev.usbharu.hideout.core.domain.model.emoji
|
||||
|
||||
import dev.usbharu.hideout.core.domain.model.instance.InstanceId
|
||||
import dev.usbharu.hideout.core.domain.model.shared.Domain
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.Domain
|
||||
import java.net.URI
|
||||
import java.time.Instant
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package dev.usbharu.hideout.core.domain.model.shared
|
||||
package dev.usbharu.hideout.core.domain.model.support.domain
|
||||
|
||||
@JvmInline
|
||||
value class Domain(val domain: String) {
|
|
@ -0,0 +1,22 @@
|
|||
package dev.usbharu.hideout.core.domain.model.support.postdetail
|
||||
|
||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
||||
import dev.usbharu.hideout.core.domain.model.post.Post
|
||||
|
||||
data class PostDetail(
|
||||
val post: Post,
|
||||
val reply: Post? = null,
|
||||
val repost: Post? = null,
|
||||
val postActor: Actor,
|
||||
val replyActor: Actor? = null,
|
||||
val repostActor: Actor? = null
|
||||
) {
|
||||
init {
|
||||
require(post.replyId == reply?.id)
|
||||
require(post.repostId == repost?.id)
|
||||
|
||||
require(post.actorId == postActor.id)
|
||||
require(reply?.actorId == replyActor?.id)
|
||||
require(repost?.actorId == repostActor?.id)
|
||||
}
|
||||
}
|
|
@ -25,6 +25,4 @@ class Timeline(
|
|||
|
||||
var name = name
|
||||
private set
|
||||
|
||||
|
||||
}
|
|
@ -2,9 +2,13 @@ package dev.usbharu.hideout.core.domain.model.timelineobject
|
|||
|
||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||
import dev.usbharu.hideout.core.domain.model.emoji.EmojiId
|
||||
import dev.usbharu.hideout.core.domain.model.filter.FilterResult
|
||||
import dev.usbharu.hideout.core.domain.model.media.MediaId
|
||||
import dev.usbharu.hideout.core.domain.model.post.Post
|
||||
import dev.usbharu.hideout.core.domain.model.post.PostContent
|
||||
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.timeline.Timeline
|
||||
import dev.usbharu.hideout.core.domain.model.timeline.TimelineId
|
||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||
import java.time.Instant
|
||||
|
@ -26,6 +30,69 @@ class TimelineObject(
|
|||
val hasMedia: Boolean,
|
||||
val hasMediaInRepost: Boolean,
|
||||
val lastUpdatedAt: Instant,
|
||||
val warnFilters: List<TimelineObjectWarnFilter>
|
||||
val warnFilters: List<TimelineObjectWarnFilter>,
|
||||
) {
|
||||
companion object {
|
||||
|
||||
fun create(
|
||||
timelineObjectId: TimelineObjectId,
|
||||
timeline: Timeline,
|
||||
post: Post,
|
||||
filterResults: List<FilterResult>
|
||||
): TimelineObject {
|
||||
return TimelineObject(
|
||||
id = timelineObjectId,
|
||||
userDetailId = timeline.userDetailId,
|
||||
timelineId = timeline.id,
|
||||
postId = post.id,
|
||||
postActorId = post.actorId,
|
||||
postCreatedAt = post.createdAt,
|
||||
replyId = post.replyId,
|
||||
repostId = null,
|
||||
visibility = post.visibility,
|
||||
isPureRepost = true,
|
||||
mediaIds = post.mediaIds,
|
||||
emojiIds = post.emojiIds,
|
||||
visibleActors = post.visibleActors.toList(),
|
||||
hasMedia = post.mediaIds.isNotEmpty(),
|
||||
hasMediaInRepost = false,
|
||||
lastUpdatedAt = Instant.now(),
|
||||
warnFilters = filterResults.map { TimelineObjectWarnFilter(it.filter.id, it.matchedKeyword) }
|
||||
)
|
||||
}
|
||||
|
||||
fun create(
|
||||
timelineObjectId: TimelineObjectId,
|
||||
timeline: Timeline,
|
||||
post: Post,
|
||||
repost: Post,
|
||||
filterResults: List<FilterResult>
|
||||
): TimelineObject {
|
||||
|
||||
require(post.repostId == repost.id)
|
||||
|
||||
return TimelineObject(
|
||||
id = timelineObjectId,
|
||||
userDetailId = timeline.userDetailId,
|
||||
timelineId = timeline.id,
|
||||
postId = post.id,
|
||||
postActorId = post.actorId,
|
||||
postCreatedAt = post.createdAt,
|
||||
replyId = post.replyId,
|
||||
repostId = repost.id,
|
||||
visibility = post.visibility,
|
||||
isPureRepost = repost.mediaIds.isEmpty() &&
|
||||
repost.overview == null &&
|
||||
repost.content == PostContent.empty &&
|
||||
repost.replyId == null,
|
||||
mediaIds = post.mediaIds,
|
||||
emojiIds = post.emojiIds,
|
||||
visibleActors = post.visibleActors.toList(),
|
||||
hasMedia = post.mediaIds.isNotEmpty(),
|
||||
hasMediaInRepost = repost.mediaIds.isNotEmpty(),
|
||||
lastUpdatedAt = Instant.now(),
|
||||
warnFilters = filterResults.map { TimelineObjectWarnFilter(it.filter.id, it.matchedKeyword) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,7 +20,7 @@ import dev.usbharu.hideout.core.domain.model.actor.*
|
|||
import dev.usbharu.hideout.core.domain.model.emoji.EmojiId
|
||||
import dev.usbharu.hideout.core.domain.model.instance.InstanceId
|
||||
import dev.usbharu.hideout.core.domain.model.media.MediaId
|
||||
import dev.usbharu.hideout.core.domain.model.shared.Domain
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.Domain
|
||||
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors
|
||||
import org.jetbrains.exposed.sql.ResultRow
|
||||
import org.springframework.stereotype.Component
|
||||
|
|
|
@ -20,7 +20,7 @@ import dev.usbharu.hideout.core.domain.model.emoji.CustomEmoji
|
|||
import dev.usbharu.hideout.core.domain.model.emoji.CustomEmojiRepository
|
||||
import dev.usbharu.hideout.core.domain.model.emoji.EmojiId
|
||||
import dev.usbharu.hideout.core.domain.model.instance.InstanceId
|
||||
import dev.usbharu.hideout.core.domain.model.shared.Domain
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.Domain
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.javatime.CurrentTimestamp
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package dev.usbharu.hideout.core.infrastructure.exposedrepository
|
||||
|
||||
import dev.usbharu.hideout.core.domain.model.actor.*
|
||||
import dev.usbharu.hideout.core.domain.model.shared.Domain
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.Domain
|
||||
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventPublisher
|
||||
import dev.usbharu.hideout.core.domain.shared.repository.DomainEventPublishableRepository
|
||||
import dev.usbharu.hideout.core.infrastructure.exposed.QueryMapper
|
||||
|
|
|
@ -19,7 +19,7 @@ package dev.usbharu.hideout.core.infrastructure.factory
|
|||
import dev.usbharu.hideout.core.config.ApplicationConfig
|
||||
import dev.usbharu.hideout.core.domain.model.actor.*
|
||||
import dev.usbharu.hideout.core.domain.model.instance.InstanceId
|
||||
import dev.usbharu.hideout.core.domain.model.shared.Domain
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.Domain
|
||||
import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService
|
||||
import org.springframework.stereotype.Component
|
||||
import java.net.URI
|
||||
|
|
|
@ -2,7 +2,7 @@ package dev.usbharu.hideout.core.domain.model.actor
|
|||
|
||||
import dev.usbharu.hideout.core.domain.model.emoji.EmojiId
|
||||
import dev.usbharu.hideout.core.domain.model.instance.InstanceId
|
||||
import dev.usbharu.hideout.core.domain.model.shared.Domain
|
||||
import dev.usbharu.hideout.core.domain.model.support.domain.Domain
|
||||
import dev.usbharu.hideout.core.infrastructure.other.TwitterSnowflakeIdGenerateService
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.net.URI
|
||||
|
|
Loading…
Reference in New Issue