mirror of https://github.com/usbharu/Hideout.git
style: fix lint
This commit is contained in:
parent
edae599978
commit
8e84c8e59c
|
@ -1,4 +1,3 @@
|
|||
package dev.usbharu.hideout.core.application.domainevent.subscribers
|
||||
|
||||
interface Subscriber {
|
||||
}
|
||||
interface Subscriber
|
||||
|
|
|
@ -5,8 +5,7 @@ import org.springframework.boot.ApplicationRunner
|
|||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class SubscriberRunner(subscribers:List<Subscriber>) : ApplicationRunner {
|
||||
class SubscriberRunner(subscribers: List<Subscriber>) : ApplicationRunner {
|
||||
override fun run(args: ApplicationArguments?) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,22 +3,20 @@ package dev.usbharu.hideout.core.application.domainevent.subscribers
|
|||
import dev.usbharu.hideout.core.domain.event.post.PostEvent
|
||||
import dev.usbharu.hideout.core.domain.event.post.PostEventBody
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.context.annotation.Scope
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class TimelinePostCreateSubscriber(domainEventSubscriber: DomainEventSubscriber) :Subscriber{
|
||||
class TimelinePostCreateSubscriber(domainEventSubscriber: DomainEventSubscriber) : Subscriber {
|
||||
init {
|
||||
domainEventSubscriber.subscribe<PostEventBody>(PostEvent.CREATE.eventName) {
|
||||
val post = it.body.getPost()
|
||||
val actor = it.body.getActor()
|
||||
|
||||
logger.info("New Post! : {}",post)
|
||||
|
||||
logger.info("New Post! : {}", post)
|
||||
}
|
||||
}
|
||||
|
||||
companion object{
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(TimelinePostCreateSubscriber::class.java)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,4 +13,4 @@ class FlywayConfig {
|
|||
migrate.migrate()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,9 @@ import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEvent
|
|||
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventBody
|
||||
|
||||
class ActorInstanceRelationshipDomainEventFactory(private val actorInstanceRelationship: ActorInstanceRelationship) {
|
||||
fun createEvent(actorInstanceRelationshipEvent: ActorInstanceRelationshipEvent): DomainEvent<ActorInstanceRelationshipEventBody> {
|
||||
fun createEvent(
|
||||
actorInstanceRelationshipEvent: ActorInstanceRelationshipEvent
|
||||
): DomainEvent<ActorInstanceRelationshipEventBody> {
|
||||
return DomainEvent.create(
|
||||
actorInstanceRelationshipEvent.eventName,
|
||||
ActorInstanceRelationshipEventBody(actorInstanceRelationship)
|
||||
|
|
|
@ -13,4 +13,4 @@ class TimelineEventBody(timeline: Timeline) : DomainEventBody(mapOf("timeline" t
|
|||
|
||||
enum class TimelineEvent(val eventName: String) {
|
||||
CHANGE_VISIBILITY("ChangeVisibility")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,4 +3,4 @@ package dev.usbharu.hideout.core.domain.model.followtimeline
|
|||
import dev.usbharu.hideout.core.domain.model.timeline.TimelineId
|
||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||
|
||||
class FollowTimeline(val userDetailId: UserDetailId, val timelineId: TimelineId)
|
||||
class FollowTimeline(val userDetailId: UserDetailId, val timelineId: TimelineId)
|
||||
|
|
|
@ -3,4 +3,4 @@ package dev.usbharu.hideout.core.domain.model.followtimeline
|
|||
interface FollowTimelineRepository {
|
||||
suspend fun save(followTimeline: FollowTimeline): FollowTimeline
|
||||
suspend fun delete(followTimeline: FollowTimeline)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ class Post(
|
|||
moveTo: PostId?,
|
||||
) : DomainEventStorable() {
|
||||
|
||||
|
||||
val actorId = actorId
|
||||
get() {
|
||||
if (deleted) {
|
||||
|
@ -271,7 +270,6 @@ class Post(
|
|||
")"
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
@Suppress("LongParameterList")
|
||||
fun create(
|
||||
|
|
|
@ -29,11 +29,10 @@ interface RelationshipRepository {
|
|||
): List<Relationship>
|
||||
}
|
||||
|
||||
|
||||
data class FindRelationshipOption(
|
||||
val follow: Boolean? = null,
|
||||
val block: Boolean? = null,
|
||||
val mute: Boolean? = null,
|
||||
val followRequest: Boolean? = null,
|
||||
val muteFollowRequest: Boolean? = null
|
||||
)
|
||||
)
|
||||
|
|
|
@ -43,4 +43,4 @@ sealed class Page {
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package dev.usbharu.hideout.core.domain.model.support.page
|
||||
|
||||
class PaginationList<T, ID>(list: List<T>, val next: ID?, val prev: ID?) : List<T> by list
|
||||
class PaginationList<T, ID>(list: List<T>, val next: ID?, val prev: ID?) : List<T> by list
|
||||
|
|
|
@ -19,4 +19,4 @@ data class PostDetail(
|
|||
require(reply?.actorId == replyActor?.id)
|
||||
require(repost?.actorId == repostActor?.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,4 +50,4 @@ data class TimelineObjectDetail(
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,4 +25,4 @@ class Timeline(
|
|||
|
||||
var name = name
|
||||
private set
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,4 +7,4 @@ interface TimelineRepository {
|
|||
suspend fun findByIds(ids: List<TimelineId>): List<Timeline>
|
||||
|
||||
suspend fun findById(id: TimelineId): Timeline?
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,4 +4,4 @@ enum class TimelineVisibility {
|
|||
PRIVATE,
|
||||
UNLISTED,
|
||||
PUBLIC
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,6 @@ class TimelineObject(
|
|||
repost: Post,
|
||||
filterResults: List<FilterResult>
|
||||
): TimelineObject {
|
||||
|
||||
require(post.repostId == repost.id)
|
||||
|
||||
return TimelineObject(
|
||||
|
@ -138,4 +137,4 @@ class TimelineObject(
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,4 @@ package dev.usbharu.hideout.core.domain.model.timelineobject
|
|||
|
||||
import dev.usbharu.hideout.core.domain.model.filter.FilterId
|
||||
|
||||
class TimelineObjectWarnFilter(val filterId: FilterId, val matchedKeyword: String) {
|
||||
|
||||
}
|
||||
class TimelineObjectWarnFilter(val filterId: FilterId, val matchedKeyword: String)
|
||||
|
|
|
@ -15,4 +15,4 @@ enum class Visible {
|
|||
UNLISTED,
|
||||
FOLLOWERS,
|
||||
DIRECT
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,4 +7,4 @@ interface TimelineRelationshipRepository {
|
|||
suspend fun delete(timelineRelationship: TimelineRelationship)
|
||||
|
||||
suspend fun findByActorId(actorId: ActorId): List<TimelineRelationship>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,4 +17,4 @@ interface TimelineStore {
|
|||
suspend fun removeTimeline(timeline: Timeline)
|
||||
|
||||
suspend fun readTimeline(timeline: Timeline): List<TimelineObjectDetail>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,17 +171,20 @@ class ExposedPostRepository(
|
|||
}
|
||||
.let(postQueryMapper::map)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override suspend fun findByActorId(id: ActorId, page: Page?): PaginationList<Post, PostId> = PaginationList(query {
|
||||
Posts
|
||||
.selectAll()
|
||||
.where {
|
||||
actorId eq actorId
|
||||
}
|
||||
.let(postQueryMapper::map)
|
||||
}, null, null)
|
||||
override suspend fun findByActorId(id: ActorId, page: Page?): PaginationList<Post, PostId> = PaginationList(
|
||||
query {
|
||||
Posts
|
||||
.selectAll()
|
||||
.where {
|
||||
actorId eq actorId
|
||||
}
|
||||
.let(postQueryMapper::map)
|
||||
},
|
||||
null,
|
||||
null
|
||||
)
|
||||
|
||||
override suspend fun delete(post: Post) {
|
||||
query {
|
||||
|
@ -197,14 +200,18 @@ class ExposedPostRepository(
|
|||
visibilityList: List<Visibility>,
|
||||
of: Page?
|
||||
): PaginationList<Post, PostId> {
|
||||
return PaginationList(query {
|
||||
Posts
|
||||
.selectAll()
|
||||
.where {
|
||||
Posts.actorId eq actorId.id and (visibility inList visibilityList.map { it.name })
|
||||
}
|
||||
.let(postQueryMapper::map)
|
||||
}, null, null)
|
||||
return PaginationList(
|
||||
query {
|
||||
Posts
|
||||
.selectAll()
|
||||
.where {
|
||||
Posts.actorId eq actorId.id and (visibility inList visibilityList.map { it.name })
|
||||
}
|
||||
.let(postQueryMapper::map)
|
||||
},
|
||||
null,
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -74,7 +74,7 @@ class ExposedRelationshipRepository(override val domainEventPublisher: DomainEve
|
|||
): List<Relationship> {
|
||||
val query1 = Relationships.selectAll().where { Relationships.actorId eq targetId.id }
|
||||
inverseOption.apply(query1)
|
||||
//todo 逆のほうがいいかも
|
||||
// todo 逆のほうがいいかも
|
||||
val query = query1.alias("INV").selectAll().where {
|
||||
Relationships.targetActorId eq targetId.id
|
||||
}
|
||||
|
@ -89,7 +89,6 @@ class ExposedRelationshipRepository(override val domainEventPublisher: DomainEve
|
|||
}
|
||||
|
||||
fun FindRelationshipOption?.apply(query: Query) {
|
||||
|
||||
if (this?.follow != null) {
|
||||
query.andWhere { Relationships.following eq this@apply.follow }
|
||||
}
|
||||
|
|
|
@ -65,4 +65,4 @@ object TimelineRelationships : Table("timeline_relationships") {
|
|||
val actorId = long("actor_id").references(Actors.id)
|
||||
val visible = varchar("visible", 100)
|
||||
override val primaryKey: PrimaryKey = PrimaryKey(id)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,10 @@ import org.slf4j.LoggerFactory
|
|||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
class ExposedTimelineRepository(override val domainEventPublisher: DomainEventPublisher) : TimelineRepository,
|
||||
AbstractRepository(), DomainEventPublishableRepository<Timeline> {
|
||||
class ExposedTimelineRepository(override val domainEventPublisher: DomainEventPublisher) :
|
||||
TimelineRepository,
|
||||
AbstractRepository(),
|
||||
DomainEventPublishableRepository<Timeline> {
|
||||
override suspend fun save(timeline: Timeline): Timeline {
|
||||
query {
|
||||
Timelines.insert {
|
||||
|
@ -54,7 +56,6 @@ class ExposedTimelineRepository(override val domainEventPublisher: DomainEventPu
|
|||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
}
|
||||
|
||||
fun ResultRow.toTimeline(): Timeline {
|
||||
|
@ -75,4 +76,4 @@ object Timelines : Table("timelines") {
|
|||
val isSystem = bool("is_system")
|
||||
|
||||
override val primaryKey: PrimaryKey = PrimaryKey(id)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,9 @@ import org.springframework.stereotype.Repository
|
|||
import java.time.Instant
|
||||
|
||||
@Repository
|
||||
class MongoInternalTimelineObjectRepository(private val springDataMongoTimelineObjectRepository: SpringDataMongoTimelineObjectRepository) :
|
||||
class MongoInternalTimelineObjectRepository(
|
||||
private val springDataMongoTimelineObjectRepository: SpringDataMongoTimelineObjectRepository
|
||||
) :
|
||||
InternalTimelineObjectRepository {
|
||||
override suspend fun save(timelineObject: TimelineObject): TimelineObject {
|
||||
springDataMongoTimelineObjectRepository.save(SpringDataMongoTimelineObject.of(timelineObject))
|
||||
|
@ -55,8 +57,6 @@ class MongoInternalTimelineObjectRepository(private val springDataMongoTimelineO
|
|||
return springDataMongoTimelineObjectRepository.findByTimelineId(timelineId).map { it.toTimelineObject() }
|
||||
.toList()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Document
|
||||
|
@ -162,4 +162,4 @@ interface SpringDataMongoTimelineObjectRepository : CoroutineCrudRepository<Spri
|
|||
suspend fun deleteByTimelineId(timelineId: Long)
|
||||
|
||||
suspend fun findByTimelineId(timelineId: TimelineId): Flow<SpringDataMongoTimelineObject>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@ class SpringFrameworkDomainEventSubscriber : DomainEventSubscriber {
|
|||
map[domainEvent.name]?.forEach {
|
||||
try {
|
||||
it.invoke(domainEvent)
|
||||
}
|
||||
catch (e: Exception) {
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,11 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
|
|||
}
|
||||
|
||||
return TimelineObject.create(
|
||||
TimelineObjectId(idGenerateService.generateId()), timeline, post, replyActorId, applyFilters.filterResults
|
||||
TimelineObjectId(idGenerateService.generateId()),
|
||||
timeline,
|
||||
post,
|
||||
replyActorId,
|
||||
applyFilters.filterResults
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -198,12 +202,20 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
|
|||
val newerFilters = getNewerFilters(timeline.userDetailId, lastUpdatedAt)
|
||||
|
||||
val posts =
|
||||
getPostsByPostId(timelineObjectList.map { it.postId } + timelineObjectList.mapNotNull { it.repostId } + timelineObjectList.mapNotNull { it.replyId })
|
||||
getPostsByPostId(
|
||||
timelineObjectList.map {
|
||||
it.postId
|
||||
} + timelineObjectList.mapNotNull { it.repostId } + timelineObjectList.mapNotNull { it.replyId }
|
||||
)
|
||||
|
||||
val userDetails = getUserDetails(timelineObjectList.map { it.userDetailId })
|
||||
|
||||
val actors =
|
||||
getActors(timelineObjectList.map { it.postActorId } + timelineObjectList.mapNotNull { it.repostActorId } + timelineObjectList.mapNotNull { it.replyActorId })
|
||||
getActors(
|
||||
timelineObjectList.map {
|
||||
it.postActorId
|
||||
} + timelineObjectList.mapNotNull { it.repostActorId } + timelineObjectList.mapNotNull { it.replyActorId }
|
||||
)
|
||||
|
||||
val postMap = posts.associate { post ->
|
||||
post.id to applyFilters(post, newerFilters)
|
||||
|
@ -239,4 +251,4 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
|
|||
abstract suspend fun getActors(actorIds: List<ActorId>): Map<ActorId, Actor>
|
||||
|
||||
abstract suspend fun getUserDetails(userDetailIdList: List<UserDetailId>): Map<UserDetailId, UserDetail>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,4 +120,4 @@ open class DefaultTimelineStore(
|
|||
override suspend fun getUserDetails(userDetailIdList: List<UserDetailId>): Map<UserDetailId, UserDetail> {
|
||||
return userDetailRepository.findAllById(userDetailIdList).associateBy { it.id }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,4 +18,4 @@ interface InternalTimelineObjectRepository {
|
|||
|
||||
suspend fun deleteByTimelineId(timelineId: TimelineId)
|
||||
suspend fun findByTimelineId(timelineId: TimelineId): List<TimelineObject>
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue