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
|
package dev.usbharu.hideout.core.application.domainevent.subscribers
|
||||||
|
|
||||||
interface Subscriber {
|
interface Subscriber
|
||||||
}
|
|
||||||
|
|
|
@ -7,6 +7,5 @@ import org.springframework.stereotype.Component
|
||||||
@Component
|
@Component
|
||||||
class SubscriberRunner(subscribers: List<Subscriber>) : ApplicationRunner {
|
class SubscriberRunner(subscribers: List<Subscriber>) : ApplicationRunner {
|
||||||
override fun run(args: ApplicationArguments?) {
|
override fun run(args: ApplicationArguments?) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,6 @@ 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.PostEvent
|
||||||
import dev.usbharu.hideout.core.domain.event.post.PostEventBody
|
import dev.usbharu.hideout.core.domain.event.post.PostEventBody
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.context.annotation.Scope
|
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@ -14,7 +13,6 @@ class TimelinePostCreateSubscriber(domainEventSubscriber: DomainEventSubscriber)
|
||||||
val actor = it.body.getActor()
|
val actor = it.body.getActor()
|
||||||
|
|
||||||
logger.info("New Post! : {}", post)
|
logger.info("New Post! : {}", post)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,9 @@ import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEvent
|
||||||
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventBody
|
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventBody
|
||||||
|
|
||||||
class ActorInstanceRelationshipDomainEventFactory(private val actorInstanceRelationship: ActorInstanceRelationship) {
|
class ActorInstanceRelationshipDomainEventFactory(private val actorInstanceRelationship: ActorInstanceRelationship) {
|
||||||
fun createEvent(actorInstanceRelationshipEvent: ActorInstanceRelationshipEvent): DomainEvent<ActorInstanceRelationshipEventBody> {
|
fun createEvent(
|
||||||
|
actorInstanceRelationshipEvent: ActorInstanceRelationshipEvent
|
||||||
|
): DomainEvent<ActorInstanceRelationshipEventBody> {
|
||||||
return DomainEvent.create(
|
return DomainEvent.create(
|
||||||
actorInstanceRelationshipEvent.eventName,
|
actorInstanceRelationshipEvent.eventName,
|
||||||
ActorInstanceRelationshipEventBody(actorInstanceRelationship)
|
ActorInstanceRelationshipEventBody(actorInstanceRelationship)
|
||||||
|
|
|
@ -50,7 +50,6 @@ class Post(
|
||||||
moveTo: PostId?,
|
moveTo: PostId?,
|
||||||
) : DomainEventStorable() {
|
) : DomainEventStorable() {
|
||||||
|
|
||||||
|
|
||||||
val actorId = actorId
|
val actorId = actorId
|
||||||
get() {
|
get() {
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
|
@ -271,7 +270,6 @@ class Post(
|
||||||
")"
|
")"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@Suppress("LongParameterList")
|
@Suppress("LongParameterList")
|
||||||
fun create(
|
fun create(
|
||||||
|
|
|
@ -29,7 +29,6 @@ interface RelationshipRepository {
|
||||||
): List<Relationship>
|
): List<Relationship>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
data class FindRelationshipOption(
|
data class FindRelationshipOption(
|
||||||
val follow: Boolean? = null,
|
val follow: Boolean? = null,
|
||||||
val block: Boolean? = null,
|
val block: Boolean? = null,
|
||||||
|
|
|
@ -110,7 +110,6 @@ class TimelineObject(
|
||||||
repost: Post,
|
repost: Post,
|
||||||
filterResults: List<FilterResult>
|
filterResults: List<FilterResult>
|
||||||
): TimelineObject {
|
): TimelineObject {
|
||||||
|
|
||||||
require(post.repostId == repost.id)
|
require(post.repostId == repost.id)
|
||||||
|
|
||||||
return TimelineObject(
|
return TimelineObject(
|
||||||
|
|
|
@ -2,6 +2,4 @@ package dev.usbharu.hideout.core.domain.model.timelineobject
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterId
|
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)
|
.let(postQueryMapper::map)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun findByActorId(id: ActorId, page: Page?): PaginationList<Post, PostId> = PaginationList(query {
|
override suspend fun findByActorId(id: ActorId, page: Page?): PaginationList<Post, PostId> = PaginationList(
|
||||||
|
query {
|
||||||
Posts
|
Posts
|
||||||
.selectAll()
|
.selectAll()
|
||||||
.where {
|
.where {
|
||||||
actorId eq actorId
|
actorId eq actorId
|
||||||
}
|
}
|
||||||
.let(postQueryMapper::map)
|
.let(postQueryMapper::map)
|
||||||
}, null, null)
|
},
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
|
||||||
override suspend fun delete(post: Post) {
|
override suspend fun delete(post: Post) {
|
||||||
query {
|
query {
|
||||||
|
@ -197,14 +200,18 @@ class ExposedPostRepository(
|
||||||
visibilityList: List<Visibility>,
|
visibilityList: List<Visibility>,
|
||||||
of: Page?
|
of: Page?
|
||||||
): PaginationList<Post, PostId> {
|
): PaginationList<Post, PostId> {
|
||||||
return PaginationList(query {
|
return PaginationList(
|
||||||
|
query {
|
||||||
Posts
|
Posts
|
||||||
.selectAll()
|
.selectAll()
|
||||||
.where {
|
.where {
|
||||||
Posts.actorId eq actorId.id and (visibility inList visibilityList.map { it.name })
|
Posts.actorId eq actorId.id and (visibility inList visibilityList.map { it.name })
|
||||||
}
|
}
|
||||||
.let(postQueryMapper::map)
|
.let(postQueryMapper::map)
|
||||||
}, null, null)
|
},
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -89,7 +89,6 @@ class ExposedRelationshipRepository(override val domainEventPublisher: DomainEve
|
||||||
}
|
}
|
||||||
|
|
||||||
fun FindRelationshipOption?.apply(query: Query) {
|
fun FindRelationshipOption?.apply(query: Query) {
|
||||||
|
|
||||||
if (this?.follow != null) {
|
if (this?.follow != null) {
|
||||||
query.andWhere { Relationships.following eq this@apply.follow }
|
query.andWhere { Relationships.following eq this@apply.follow }
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,10 @@ import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
class ExposedTimelineRepository(override val domainEventPublisher: DomainEventPublisher) : TimelineRepository,
|
class ExposedTimelineRepository(override val domainEventPublisher: DomainEventPublisher) :
|
||||||
AbstractRepository(), DomainEventPublishableRepository<Timeline> {
|
TimelineRepository,
|
||||||
|
AbstractRepository(),
|
||||||
|
DomainEventPublishableRepository<Timeline> {
|
||||||
override suspend fun save(timeline: Timeline): Timeline {
|
override suspend fun save(timeline: Timeline): Timeline {
|
||||||
query {
|
query {
|
||||||
Timelines.insert {
|
Timelines.insert {
|
||||||
|
@ -54,7 +56,6 @@ class ExposedTimelineRepository(override val domainEventPublisher: DomainEventPu
|
||||||
|
|
||||||
override val logger: Logger
|
override val logger: Logger
|
||||||
get() = Companion.logger
|
get() = Companion.logger
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ResultRow.toTimeline(): Timeline {
|
fun ResultRow.toTimeline(): Timeline {
|
||||||
|
|
|
@ -22,7 +22,9 @@ import org.springframework.stereotype.Repository
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
class MongoInternalTimelineObjectRepository(private val springDataMongoTimelineObjectRepository: SpringDataMongoTimelineObjectRepository) :
|
class MongoInternalTimelineObjectRepository(
|
||||||
|
private val springDataMongoTimelineObjectRepository: SpringDataMongoTimelineObjectRepository
|
||||||
|
) :
|
||||||
InternalTimelineObjectRepository {
|
InternalTimelineObjectRepository {
|
||||||
override suspend fun save(timelineObject: TimelineObject): TimelineObject {
|
override suspend fun save(timelineObject: TimelineObject): TimelineObject {
|
||||||
springDataMongoTimelineObjectRepository.save(SpringDataMongoTimelineObject.of(timelineObject))
|
springDataMongoTimelineObjectRepository.save(SpringDataMongoTimelineObject.of(timelineObject))
|
||||||
|
@ -55,8 +57,6 @@ class MongoInternalTimelineObjectRepository(private val springDataMongoTimelineO
|
||||||
return springDataMongoTimelineObjectRepository.findByTimelineId(timelineId).map { it.toTimelineObject() }
|
return springDataMongoTimelineObjectRepository.findByTimelineId(timelineId).map { it.toTimelineObject() }
|
||||||
.toList()
|
.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
|
|
|
@ -21,8 +21,7 @@ class SpringFrameworkDomainEventSubscriber : DomainEventSubscriber {
|
||||||
map[domainEvent.name]?.forEach {
|
map[domainEvent.name]?.forEach {
|
||||||
try {
|
try {
|
||||||
it.invoke(domainEvent)
|
it.invoke(domainEvent)
|
||||||
}
|
} catch (e: Exception) {
|
||||||
catch (e: Exception) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,11 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
|
||||||
}
|
}
|
||||||
|
|
||||||
return TimelineObject.create(
|
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 newerFilters = getNewerFilters(timeline.userDetailId, lastUpdatedAt)
|
||||||
|
|
||||||
val posts =
|
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 userDetails = getUserDetails(timelineObjectList.map { it.userDetailId })
|
||||||
|
|
||||||
val actors =
|
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 ->
|
val postMap = posts.associate { post ->
|
||||||
post.id to applyFilters(post, newerFilters)
|
post.id to applyFilters(post, newerFilters)
|
||||||
|
|
Loading…
Reference in New Issue