refactor: 不要なQueryServiceを削除

This commit is contained in:
usbharu 2023-12-21 11:08:59 +09:00
parent 3571ab22e3
commit bf4d694aa2
35 changed files with 46 additions and 247 deletions

View File

@ -4,11 +4,11 @@ import com.fasterxml.jackson.databind.ObjectMapper
import dev.usbharu.hideout.core.domain.exception.resource.PostNotFoundException
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.domain.model.post.PostRepository
import dev.usbharu.hideout.core.domain.model.reaction.Reaction
import dev.usbharu.hideout.core.external.job.DeliverReactionJob
import dev.usbharu.hideout.core.external.job.DeliverRemoveReactionJob
import dev.usbharu.hideout.core.query.FollowerQueryService
import dev.usbharu.hideout.core.query.PostQueryService
import dev.usbharu.hideout.core.service.job.JobQueueParentService
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.stereotype.Service
@ -22,15 +22,15 @@ interface APReactionService {
class APReactionServiceImpl(
private val jobQueueParentService: JobQueueParentService,
private val followerQueryService: FollowerQueryService,
private val postQueryService: PostQueryService,
private val actorRepository: ActorRepository,
@Qualifier("activitypub") private val objectMapper: ObjectMapper
@Qualifier("activitypub") private val objectMapper: ObjectMapper,
private val postRepository: PostRepository
) : APReactionService {
override suspend fun reaction(like: Reaction) {
val followers = followerQueryService.findFollowersById(like.actorId)
val user = actorRepository.findById(like.actorId) ?: throw UserNotFoundException.withId(like.actorId)
val post =
postQueryService.findById(like.postId) ?: throw PostNotFoundException.withId(like.postId)
postRepository.findById(like.postId) ?: throw PostNotFoundException.withId(like.postId)
followers.forEach { follower ->
jobQueueParentService.schedule(DeliverReactionJob) {
props[DeliverReactionJob.actor] = user.url
@ -46,7 +46,7 @@ class APReactionServiceImpl(
val followers = followerQueryService.findFollowersById(like.actorId)
val user = actorRepository.findById(like.actorId) ?: throw UserNotFoundException.withId(like.actorId)
val post =
postQueryService.findById(like.postId) ?: throw PostNotFoundException.withId(like.postId)
postRepository.findById(like.postId) ?: throw PostNotFoundException.withId(like.postId)
followers.forEach { follower ->
jobQueueParentService.schedule(DeliverRemoveReactionJob) {
props[DeliverRemoveReactionJob.actor] = user.url

View File

@ -11,7 +11,7 @@ import dev.usbharu.hideout.core.domain.exception.resource.PostNotFoundException
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
import dev.usbharu.hideout.core.domain.exception.resource.local.LocalUserNotFoundException
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.query.PostQueryService
import dev.usbharu.hideout.core.domain.model.post.PostRepository
import dev.usbharu.hideout.core.service.reaction.ReactionService
import dev.usbharu.hideout.core.service.relationship.RelationshipService
import org.springframework.stereotype.Service
@ -21,9 +21,9 @@ class APUndoProcessor(
transaction: Transaction,
private val apUserService: APUserService,
private val relationshipService: RelationshipService,
private val postQueryService: PostQueryService,
private val reactionService: ReactionService,
private val actorRepository: ActorRepository
private val actorRepository: ActorRepository,
private val postRepository: PostRepository
) :
AbstractActivityPubProcessor<Undo>(transaction) {
override suspend fun internalProcess(activity: ActivityPubProcessContext<Undo>) {
@ -81,7 +81,7 @@ class APUndoProcessor(
val like = undo.apObject as Like
val post =
postQueryService.findByUrl(like.apObject) ?: throw PostNotFoundException.withUrl(like.apObject)
postRepository.findByUrl(like.apObject) ?: throw PostNotFoundException.withUrl(like.apObject)
val signer =
actorRepository.findById(post.actorId) ?: throw LocalUserNotFoundException.withId(post.actorId)

View File

@ -9,7 +9,6 @@ import dev.usbharu.hideout.activitypub.service.objects.user.APUserService
import dev.usbharu.hideout.core.domain.model.post.Post
import dev.usbharu.hideout.core.domain.model.post.PostRepository
import dev.usbharu.hideout.core.domain.model.post.Visibility
import dev.usbharu.hideout.core.query.PostQueryService
import dev.usbharu.hideout.core.service.media.MediaService
import dev.usbharu.hideout.core.service.media.RemoteMedia
import dev.usbharu.hideout.core.service.post.PostService
@ -29,7 +28,6 @@ interface APNoteService {
class APNoteServiceImpl(
private val postRepository: PostRepository,
private val apUserService: APUserService,
private val postQueryService: PostQueryService,
private val postService: PostService,
private val apResourceResolveService: APResourceResolveService,
private val postBuilder: Post.PostBuilder,
@ -97,7 +95,7 @@ class APNoteServiceImpl(
val reply = note.inReplyTo?.let {
fetchNote(it, targetActor)
postQueryService.findByUrl(it)
postRepository.findByUrl(it)
}
val mediaList = note.attachment.map {

View File

@ -4,4 +4,5 @@ interface DeletedActorRepository {
suspend fun save(deletedActor: DeletedActor): DeletedActor
suspend fun delete(deletedActor: DeletedActor)
suspend fun findById(id: Long): DeletedActor?
suspend fun findByNameAndDomain(name: String, domain: String): DeletedActor?
}

View File

@ -5,4 +5,5 @@ interface InstanceRepository {
suspend fun save(instance: Instance): Instance
suspend fun findById(id: Long): Instance?
suspend fun delete(instance: Instance)
suspend fun findByUrl(url:String):Instance?
}

View File

@ -5,4 +5,5 @@ interface MediaRepository {
suspend fun save(media: Media): Media
suspend fun findById(id: Long): Media?
suspend fun delete(id: Long)
suspend fun findByRemoteUrl(remoteUrl: String): Media?
}

View File

@ -10,10 +10,8 @@ interface PostRepository {
suspend fun delete(id: Long)
suspend fun findById(id: Long): Post?
suspend fun findByUrl(url: String): Post?
suspend fun findByUrl2(url: String): Post? {
throw Exception()
}
suspend fun findByApId(apId: String): Post?
suspend fun existByApIdWithLock(apId: String): Boolean
suspend fun findByActorId(actorId: Long): List<Post>
}

View File

@ -9,4 +9,8 @@ interface ReactionRepository {
suspend fun delete(reaction: Reaction): Reaction
suspend fun deleteByPostId(postId: Long): Int
suspend fun deleteByActorId(actorId: Long): Int
suspend fun findByPostId(postId: Long): List<Reaction>
suspend fun findByPostIdAndActorIdAndEmojiId(postId: Long, actorId: Long, emojiId: Long): Reaction?
suspend fun existByPostIdAndActorIdAndEmojiId(postId: Long, actorId: Long, emojiId: Long): Boolean
suspend fun findByPostIdAndActorId(postId: Long, actorId: Long): List<Reaction>
}

View File

@ -30,4 +30,15 @@ interface RelationshipRepository {
suspend fun findByUserIdAndTargetUserId(actorId: Long, targetActorId: Long): Relationship?
suspend fun deleteByActorIdOrTargetActorId(actorId: Long, targetActorId: Long)
suspend fun findByTargetIdAndFollowing(targetId: Long,following:Boolean):List<Relationship>
suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest(
maxId: Long?,
sinceId: Long?,
limit: Int,
targetId: Long,
followRequest: Boolean,
ignoreFollowRequest: Boolean
): List<Relationship>
}

View File

@ -3,7 +3,6 @@ package dev.usbharu.hideout.core.infrastructure.exposedquery
import dev.usbharu.hideout.core.domain.model.deletedActor.DeletedActor
import dev.usbharu.hideout.core.infrastructure.exposedrepository.DeletedActors
import dev.usbharu.hideout.core.infrastructure.exposedrepository.toDeletedActor
import dev.usbharu.hideout.core.query.DeletedActorQueryService
import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.select
import org.springframework.stereotype.Repository

View File

@ -4,18 +4,16 @@ import dev.usbharu.hideout.core.domain.model.actor.Actor
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
import dev.usbharu.hideout.core.query.FollowerQueryService
import dev.usbharu.hideout.core.query.RelationshipQueryService
import org.springframework.stereotype.Repository
@Repository
class FollowerQueryServiceImpl(
private val relationshipQueryService: RelationshipQueryService,
private val relationshipRepository: RelationshipRepository,
private val actorRepository: ActorRepository
) : FollowerQueryService {
override suspend fun findFollowersById(id: Long): List<Actor> {
return actorRepository.findByIds(
relationshipQueryService.findByTargetIdAndFollowing(id, true).map { it.actorId }
relationshipRepository.findByTargetIdAndFollowing(id, true).map { it.actorId }
)
}

View File

@ -2,7 +2,6 @@ package dev.usbharu.hideout.core.infrastructure.exposedquery
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Instance
import dev.usbharu.hideout.core.infrastructure.exposedrepository.toInstance
import dev.usbharu.hideout.core.query.InstanceQueryService
import org.jetbrains.exposed.sql.select
import org.springframework.stereotype.Repository
import dev.usbharu.hideout.core.domain.model.instance.Instance as InstanceEntity

View File

@ -1,25 +1,13 @@
package dev.usbharu.hideout.core.infrastructure.exposedquery
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Media
import dev.usbharu.hideout.core.infrastructure.exposedrepository.PostsMedia
import dev.usbharu.hideout.core.infrastructure.exposedrepository.toMedia
import dev.usbharu.hideout.core.query.MediaQueryService
import org.jetbrains.exposed.sql.innerJoin
import org.jetbrains.exposed.sql.select
import org.springframework.stereotype.Repository
import dev.usbharu.hideout.core.domain.model.media.Media as MediaEntity
@Repository
class MediaQueryServiceImpl : MediaQueryService {
override suspend fun findByPostId(postId: Long): List<MediaEntity> {
return Media.innerJoin(
PostsMedia,
onColumn = { id },
otherColumn = { mediaId }
)
.select { PostsMedia.postId eq postId }
.map { it.toMedia() }
}
override suspend fun findByRemoteUrl(remoteUrl: String): MediaEntity? {
return Media.select { Media.remoteUrl eq remoteUrl }.forUpdate()

View File

@ -1,37 +0,0 @@
package dev.usbharu.hideout.core.infrastructure.exposedquery
import dev.usbharu.hideout.application.infrastructure.exposed.QueryMapper
import dev.usbharu.hideout.application.infrastructure.exposed.ResultRowMapper
import dev.usbharu.hideout.core.domain.model.post.Post
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Posts
import dev.usbharu.hideout.core.infrastructure.exposedrepository.PostsMedia
import dev.usbharu.hideout.core.query.PostQueryService
import org.jetbrains.exposed.sql.select
import org.springframework.stereotype.Repository
@Repository
class PostQueryServiceImpl(
private val postResultRowMapper: ResultRowMapper<Post>,
private val postQueryMapper: QueryMapper<Post>
) : PostQueryService {
override suspend fun findById(id: Long): Post? =
Posts.leftJoin(PostsMedia)
.select { Posts.id eq id }
.singleOrNull()
?.let(postResultRowMapper::map)
override suspend fun findByUrl(url: String): Post? =
Posts.leftJoin(PostsMedia)
.select { Posts.url eq url }
.let(postQueryMapper::map)
.singleOrNull()
override suspend fun findByApId(string: String): Post? =
Posts.leftJoin(PostsMedia)
.select { Posts.apId eq string }
.let(postQueryMapper::map)
.singleOrNull()
override suspend fun findByActorId(actorId: Long): List<Post> =
Posts.leftJoin(PostsMedia).select { Posts.actorId eq actorId }.let(postQueryMapper::map)
}

View File

@ -1,43 +1,8 @@
package dev.usbharu.hideout.core.infrastructure.exposedquery
import dev.usbharu.hideout.core.domain.model.reaction.Reaction
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Reactions
import dev.usbharu.hideout.core.infrastructure.exposedrepository.toReaction
import dev.usbharu.hideout.core.query.ReactionQueryService
import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.select
import org.springframework.stereotype.Repository
@Repository
class ReactionQueryServiceImpl : ReactionQueryService {
override suspend fun findByPostId(postId: Long, actorId: Long?): List<Reaction> {
return Reactions.select {
Reactions.postId.eq(postId)
}.map { it.toReaction() }
}
@Suppress("FunctionMaxLength")
override suspend fun findByPostIdAndActorIdAndEmojiId(postId: Long, actorId: Long, emojiId: Long): Reaction? {
return Reactions
.select {
Reactions.postId.eq(postId).and(Reactions.actorId.eq(actorId)).and(
Reactions.emojiId.eq(emojiId)
)
}
.singleOrNull()
?.toReaction()
}
override suspend fun reactionAlreadyExist(postId: Long, actorId: Long, emojiId: Long): Boolean {
return Reactions.select {
Reactions.postId.eq(postId).and(Reactions.actorId.eq(actorId)).and(
Reactions.emojiId.eq(emojiId)
)
}.empty().not()
}
override suspend fun findByPostIdAndActorId(postId: Long, actorId: Long): List<Reaction> {
return Reactions.select { Reactions.postId eq postId and (Reactions.actorId eq actorId) }
.map { it.toReaction() }
}
}

View File

@ -1,43 +1,8 @@
package dev.usbharu.hideout.core.infrastructure.exposedquery
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
import dev.usbharu.hideout.core.domain.model.relationship.Relationships
import dev.usbharu.hideout.core.domain.model.relationship.toRelationships
import dev.usbharu.hideout.core.query.RelationshipQueryService
import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.andWhere
import org.jetbrains.exposed.sql.select
import org.springframework.stereotype.Service
@Service
class RelationshipQueryServiceImpl : RelationshipQueryService {
override suspend fun findByTargetIdAndFollowing(targetId: Long, following: Boolean): List<Relationship> =
Relationships.select { Relationships.targetActorId eq targetId and (Relationships.following eq following) }
.map { it.toRelationships() }
override suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest(
maxId: Long?,
sinceId: Long?,
limit: Int,
targetId: Long,
followRequest: Boolean,
ignoreFollowRequest: Boolean
): List<Relationship> {
val query = Relationships
.select {
Relationships.targetActorId.eq(targetId)
.and(Relationships.followRequest.eq(followRequest))
.and(Relationships.ignoreFollowRequestFromTarget.eq(ignoreFollowRequest))
}.limit(limit)
if (maxId != null) {
query.andWhere { Relationships.id greater maxId }
}
if (sinceId != null) {
query.andWhere { Relationships.id less sinceId }
}
return query.map { it.toRelationships() }
}
}

View File

@ -1,7 +0,0 @@
package dev.usbharu.hideout.core.query
import dev.usbharu.hideout.core.domain.model.deletedActor.DeletedActor
interface DeletedActorQueryService {
suspend fun findByNameAndDomain(name: String, domain: String): DeletedActor?
}

View File

@ -1,7 +0,0 @@
package dev.usbharu.hideout.core.query
import dev.usbharu.hideout.core.domain.model.instance.Instance
interface InstanceQueryService {
suspend fun findByUrl(url: String): Instance?
}

View File

@ -1,8 +0,0 @@
package dev.usbharu.hideout.core.query
import dev.usbharu.hideout.core.domain.model.media.Media
interface MediaQueryService {
suspend fun findByPostId(postId: Long): List<Media>
suspend fun findByRemoteUrl(remoteUrl: String): Media?
}

View File

@ -1,12 +0,0 @@
package dev.usbharu.hideout.core.query
import dev.usbharu.hideout.core.domain.model.post.Post
import org.springframework.stereotype.Repository
@Repository
interface PostQueryService {
suspend fun findById(id: Long): Post?
suspend fun findByUrl(url: String): Post?
suspend fun findByApId(string: String): Post?
suspend fun findByActorId(actorId: Long): List<Post>
}

View File

@ -1,16 +0,0 @@
package dev.usbharu.hideout.core.query
import dev.usbharu.hideout.core.domain.model.reaction.Reaction
import org.springframework.stereotype.Repository
@Repository
interface ReactionQueryService {
suspend fun findByPostId(postId: Long, actorId: Long? = null): List<Reaction>
@Suppress("FunctionMaxLength")
suspend fun findByPostIdAndActorIdAndEmojiId(postId: Long, actorId: Long, emojiId: Long): Reaction?
suspend fun reactionAlreadyExist(postId: Long, actorId: Long, emojiId: Long): Boolean
suspend fun findByPostIdAndActorId(postId: Long, actorId: Long): List<Reaction>
}

View File

@ -1,18 +0,0 @@
package dev.usbharu.hideout.core.query
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
interface RelationshipQueryService {
suspend fun findByTargetIdAndFollowing(targetId: Long, following: Boolean): List<Relationship>
@Suppress("LongParameterList", "FunctionMaxLength")
suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest(
maxId: Long?,
sinceId: Long?,
limit: Int,
targetId: Long,
followRequest: Boolean,
ignoreFollowRequest: Boolean
): List<Relationship>
}

View File

@ -5,7 +5,6 @@ import dev.usbharu.hideout.core.domain.model.instance.Instance
import dev.usbharu.hideout.core.domain.model.instance.InstanceRepository
import dev.usbharu.hideout.core.domain.model.instance.Nodeinfo
import dev.usbharu.hideout.core.domain.model.instance.Nodeinfo2_0
import dev.usbharu.hideout.core.query.InstanceQueryService
import dev.usbharu.hideout.core.service.resource.ResourceResolveService
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Qualifier
@ -22,14 +21,13 @@ interface InstanceService {
class InstanceServiceImpl(
private val instanceRepository: InstanceRepository,
private val resourceResolveService: ResourceResolveService,
@Qualifier("activitypub") private val objectMapper: ObjectMapper,
private val instanceQueryService: InstanceQueryService
@Qualifier("activitypub") private val objectMapper: ObjectMapper
) : InstanceService {
override suspend fun fetchInstance(url: String, sharedInbox: String?): Instance {
val u = URL(url)
val resolveInstanceUrl = u.protocol + "://" + u.host
val instance = instanceQueryService.findByUrl(resolveInstanceUrl)
val instance = instanceRepository.findByUrl(resolveInstanceUrl)
if (instance != null) {
return instance

View File

@ -4,7 +4,6 @@ import dev.usbharu.hideout.core.domain.exception.media.MediaSaveException
import dev.usbharu.hideout.core.domain.exception.media.UnsupportedMediaException
import dev.usbharu.hideout.core.domain.model.media.Media
import dev.usbharu.hideout.core.domain.model.media.MediaRepository
import dev.usbharu.hideout.core.query.MediaQueryService
import dev.usbharu.hideout.core.service.media.converter.MediaProcessService
import dev.usbharu.hideout.mastodon.interfaces.api.media.MediaRequest
import dev.usbharu.hideout.util.withDelete
@ -23,8 +22,7 @@ class MediaServiceImpl(
private val mediaRepository: MediaRepository,
private val mediaProcessServices: List<MediaProcessService>,
private val remoteMediaDownloadService: RemoteMediaDownloadService,
private val renameService: MediaFileRenameService,
private val mediaQueryService: MediaQueryService
private val renameService: MediaFileRenameService
) : MediaService {
@Suppress("LongMethod", "NestedBlockDepth")
override suspend fun uploadLocalMedia(mediaRequest: MediaRequest): EntityMedia {
@ -102,7 +100,7 @@ class MediaServiceImpl(
logger.info("MEDIA Remote media. filename:${remoteMedia.name} url:${remoteMedia.url}")
val findByRemoteUrl = mediaQueryService.findByRemoteUrl(remoteMedia.url)
val findByRemoteUrl = mediaRepository.findByRemoteUrl(remoteMedia.url)
if (findByRemoteUrl != null) {
logger.warn("DUPLICATED Remote media is duplicated. url: {}", remoteMedia.url)
return findByRemoteUrl

View File

@ -9,7 +9,6 @@ import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.domain.model.post.Post
import dev.usbharu.hideout.core.domain.model.post.PostRepository
import dev.usbharu.hideout.core.domain.model.reaction.ReactionRepository
import dev.usbharu.hideout.core.query.PostQueryService
import dev.usbharu.hideout.core.service.timeline.TimelineService
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
@ -20,7 +19,6 @@ class PostServiceImpl(
private val postRepository: PostRepository,
private val actorRepository: ActorRepository,
private val timelineService: TimelineService,
private val postQueryService: PostQueryService,
private val postBuilder: Post.PostBuilder,
private val apSendCreateService: ApSendCreateService,
private val reactionRepository: ReactionRepository
@ -69,7 +67,7 @@ class PostServiceImpl(
}
override suspend fun deleteByActor(actorId: Long) {
postQueryService.findByActorId(actorId).filterNot { it.delted }.forEach { postRepository.save(it.delete()) }
postRepository.findByActorId(actorId).filterNot { it.delted }.forEach { postRepository.save(it.delete()) }
val actor = actorRepository.findById(actorId)
?: throw IllegalStateException("actor: $actorId was not found.")

View File

@ -3,7 +3,6 @@ package dev.usbharu.hideout.core.service.reaction
import dev.usbharu.hideout.activitypub.service.activity.like.APReactionService
import dev.usbharu.hideout.core.domain.model.reaction.Reaction
import dev.usbharu.hideout.core.domain.model.reaction.ReactionRepository
import dev.usbharu.hideout.core.query.ReactionQueryService
import org.jetbrains.exposed.exceptions.ExposedSQLException
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@ -12,11 +11,10 @@ import org.springframework.stereotype.Service
@Service
class ReactionServiceImpl(
private val reactionRepository: ReactionRepository,
private val apReactionService: APReactionService,
private val reactionQueryService: ReactionQueryService
private val apReactionService: APReactionService
) : ReactionService {
override suspend fun receiveReaction(name: String, domain: String, actorId: Long, postId: Long) {
if (reactionQueryService.reactionAlreadyExist(postId, actorId, 0).not()) {
if (reactionRepository.existByPostIdAndActorIdAndEmojiId(postId, actorId, 0).not()) {
try {
reactionRepository.save(
Reaction(reactionRepository.generateId(), 0, postId, actorId)
@ -27,7 +25,7 @@ class ReactionServiceImpl(
}
override suspend fun receiveRemoveReaction(actorId: Long, postId: Long) {
val reaction = reactionQueryService.findByPostIdAndActorIdAndEmojiId(postId, actorId, 0)
val reaction = reactionRepository.findByPostIdAndActorIdAndEmojiId(postId, actorId, 0)
if (reaction == null) {
LOGGER.warn("FAILED receive Remove Reaction. $actorId $postId")
return
@ -37,7 +35,7 @@ class ReactionServiceImpl(
override suspend fun sendReaction(name: String, actorId: Long, postId: Long) {
val findByPostIdAndUserIdAndEmojiId =
reactionQueryService.findByPostIdAndActorIdAndEmojiId(postId, actorId, 0)
reactionRepository.findByPostIdAndActorIdAndEmojiId(postId, actorId, 0)
if (findByPostIdAndUserIdAndEmojiId == null) {
LOGGER.warn("FAILED Send reaction. $postId $actorId")
@ -53,7 +51,7 @@ class ReactionServiceImpl(
override suspend fun removeReaction(actorId: Long, postId: Long) {
val findByPostIdAndUserIdAndEmojiId =
reactionQueryService.findByPostIdAndActorIdAndEmojiId(postId, actorId, 0)
reactionRepository.findByPostIdAndActorIdAndEmojiId(postId, actorId, 0)
if (findByPostIdAndUserIdAndEmojiId == null) {
LOGGER.warn("FAILED Remove reaction. actorId: $actorId postId: $postId")
return

View File

@ -12,7 +12,6 @@ import dev.usbharu.hideout.core.domain.model.reaction.ReactionRepository
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetail
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
import dev.usbharu.hideout.core.query.DeletedActorQueryService
import dev.usbharu.hideout.core.service.instance.InstanceService
import dev.usbharu.hideout.core.service.post.PostService
import org.slf4j.LoggerFactory
@ -29,7 +28,6 @@ class UserServiceImpl(
private val instanceService: InstanceService,
private val userDetailRepository: UserDetailRepository,
private val deletedActorRepository: DeletedActorRepository,
private val deletedActorQueryService: DeletedActorQueryService,
private val reactionRepository: ReactionRepository,
private val relationshipRepository: RelationshipRepository,
private val postService: PostService,
@ -73,7 +71,7 @@ class UserServiceImpl(
override suspend fun createRemoteUser(user: RemoteUserCreateDto): Actor {
logger.info("START Create New remote user. name: {} url: {}", user.name, user.url)
val deletedActor = deletedActorQueryService.findByNameAndDomain(user.name, user.domain)
val deletedActor = deletedActorRepository.findByNameAndDomain(user.name, user.domain)
if (deletedActor != null) {
logger.warn("FAILED Deleted actor. user: ${user.name} domain: ${user.domain}")

View File

@ -2,7 +2,6 @@ package dev.usbharu.hideout.mastodon.service.account
import dev.usbharu.hideout.application.external.Transaction
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
import dev.usbharu.hideout.core.query.RelationshipQueryService
import dev.usbharu.hideout.core.service.media.MediaService
import dev.usbharu.hideout.core.service.relationship.RelationshipService
import dev.usbharu.hideout.core.service.user.UpdateUserDto
@ -221,7 +220,7 @@ class AccountApiServiceImpl(
limit: Int,
withIgnore: Boolean
): List<Account> = transaction.transaction {
val actorIdList = relationshipQueryService
val actorIdList = relationshipRepository
.findByTargetIdAndFollowRequestAndIgnoreFollowRequest(
maxId = maxId,
sinceId = sinceId,

View File

@ -4,7 +4,7 @@ import dev.usbharu.hideout.application.external.Transaction
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.domain.model.media.MediaRepository
import dev.usbharu.hideout.core.domain.model.media.toMediaAttachments
import dev.usbharu.hideout.core.query.PostQueryService
import dev.usbharu.hideout.core.domain.model.post.PostRepository
import dev.usbharu.hideout.core.service.post.PostCreateDto
import dev.usbharu.hideout.core.service.post.PostService
import dev.usbharu.hideout.domain.mastodon.model.generated.Status
@ -28,10 +28,10 @@ interface StatusesApiService {
class StatsesApiServiceImpl(
private val postService: PostService,
private val accountService: AccountService,
private val postQueryService: PostQueryService,
private val mediaRepository: MediaRepository,
private val transaction: Transaction,
private val actorRepository: ActorRepository
private val actorRepository: ActorRepository,
private val postRepository: PostRepository
) :
StatusesApiService {
override suspend fun postStatus(
@ -53,7 +53,7 @@ class StatsesApiServiceImpl(
val account = accountService.findById(userId)
val replyUser = if (post.replyId != null) {
val findById = postQueryService.findById(post.replyId)
val findById = postRepository.findById(post.replyId)
if (findById == null) {
null
} else {

View File

@ -6,7 +6,6 @@ import dev.usbharu.hideout.core.domain.model.reaction.Reaction
import dev.usbharu.hideout.core.external.job.DeliverReactionJob
import dev.usbharu.hideout.core.external.job.DeliverRemoveReactionJob
import dev.usbharu.hideout.core.query.FollowerQueryService
import dev.usbharu.hideout.core.query.PostQueryService
import dev.usbharu.hideout.core.service.job.JobQueueParentService
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Test

View File

@ -16,7 +16,6 @@ import dev.usbharu.hideout.application.service.id.TwitterSnowflakeIdGenerateServ
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
import dev.usbharu.hideout.core.domain.model.post.Post
import dev.usbharu.hideout.core.domain.model.post.PostRepository
import dev.usbharu.hideout.core.query.PostQueryService
import dev.usbharu.hideout.core.service.post.PostService
import io.ktor.client.*
import io.ktor.client.call.*
@ -70,7 +69,6 @@ class APNoteServiceImplTest {
val apNoteServiceImpl = APNoteServiceImpl(
postRepository = mock(),
apUserService = mock(),
postQueryService = mock(),
postService = mock(),
apResourceResolveService = mock(),
postBuilder = Post.PostBuilder(CharacterLimit()),
@ -144,7 +142,6 @@ class APNoteServiceImplTest {
val apNoteServiceImpl = APNoteServiceImpl(
postRepository = postRepository,
apUserService = apUserService,
postQueryService = postQueryService,
postService = mock(),
apResourceResolveService = apResourceResolveService,
postBuilder = Post.PostBuilder(CharacterLimit()),
@ -211,7 +208,6 @@ class APNoteServiceImplTest {
val apNoteServiceImpl = APNoteServiceImpl(
postRepository = mock(),
apUserService = mock(),
postQueryService = postQueryService,
postService = mock(),
apResourceResolveService = apResourceResolveService,
postBuilder = Post.PostBuilder(CharacterLimit()),
@ -262,7 +258,6 @@ class APNoteServiceImplTest {
val apNoteServiceImpl = APNoteServiceImpl(
postRepository = postRepository,
apUserService = apUserService,
postQueryService = mock(),
postService = postService,
apResourceResolveService = mock(),
postBuilder = postBuilder,
@ -318,7 +313,6 @@ class APNoteServiceImplTest {
val apNoteServiceImpl = APNoteServiceImpl(
postRepository = mock(),
apUserService = mock(),
postQueryService = mock(),
postService = mock(),
apResourceResolveService = mock(),
postBuilder = postBuilder,

View File

@ -6,7 +6,6 @@ import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.domain.model.post.Post
import dev.usbharu.hideout.core.domain.model.post.PostRepository
import dev.usbharu.hideout.core.domain.model.reaction.ReactionRepository
import dev.usbharu.hideout.core.query.PostQueryService
import dev.usbharu.hideout.core.service.timeline.TimelineService
import kotlinx.coroutines.test.runTest
import org.assertj.core.api.Assertions.assertThat

View File

@ -6,7 +6,6 @@ import dev.usbharu.hideout.application.service.id.TwitterSnowflakeIdGenerateServ
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
import dev.usbharu.hideout.core.domain.model.reaction.Reaction
import dev.usbharu.hideout.core.domain.model.reaction.ReactionRepository
import dev.usbharu.hideout.core.query.ReactionQueryService
import kotlinx.coroutines.test.runTest
import org.jetbrains.exposed.exceptions.ExposedSQLException
import org.junit.jupiter.api.Test

View File

@ -8,7 +8,6 @@ import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
import dev.usbharu.hideout.core.domain.model.actor.Actor
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.domain.model.post.Post
import dev.usbharu.hideout.core.query.DeletedActorQueryService
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Test
@ -43,7 +42,6 @@ class ActorServiceTest {
instanceService = mock(),
userDetailRepository = mock(),
deletedActorRepository = mock(),
deletedActorQueryService = mock(),
reactionRepository = mock(),
relationshipRepository = mock(),
postService = mock(),
@ -89,7 +87,6 @@ class ActorServiceTest {
instanceService = mock(),
userDetailRepository = mock(),
deletedActorRepository = mock(),
deletedActorQueryService = deletedActorQueryService,
reactionRepository = mock(),
relationshipRepository = mock(),
postService = mock(),

View File

@ -4,7 +4,6 @@ import dev.usbharu.hideout.application.external.Transaction
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
import dev.usbharu.hideout.core.query.FollowerQueryService
import dev.usbharu.hideout.core.query.RelationshipQueryService
import dev.usbharu.hideout.core.service.media.MediaService
import dev.usbharu.hideout.core.service.relationship.RelationshipService
import dev.usbharu.hideout.core.service.user.UserService