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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,7 +29,6 @@ interface RelationshipRepository {
|
|||
): List<Relationship>
|
||||
}
|
||||
|
||||
|
||||
data class FindRelationshipOption(
|
||||
val follow: Boolean? = null,
|
||||
val block: Boolean? = null,
|
||||
|
|
|
@ -110,7 +110,6 @@ class TimelineObject(
|
|||
repost: Post,
|
||||
filterResults: List<FilterResult>
|
||||
): TimelineObject {
|
||||
|
||||
require(post.repostId == repost.id)
|
||||
|
||||
return 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)
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue