refactor: jobを別のクラスに切り出し

This commit is contained in:
usbharu 2023-10-27 13:22:18 +09:00
parent 1118ca30fb
commit ab25e136dd
12 changed files with 236 additions and 168 deletions

View File

@ -1,10 +1,6 @@
package dev.usbharu.hideout.service.ap package dev.usbharu.hideout.service.ap
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.config.ApplicationConfig
import dev.usbharu.hideout.domain.model.ap.Create
import dev.usbharu.hideout.domain.model.ap.Document
import dev.usbharu.hideout.domain.model.ap.Note import dev.usbharu.hideout.domain.model.ap.Note
import dev.usbharu.hideout.domain.model.hideout.entity.Post import dev.usbharu.hideout.domain.model.hideout.entity.Post
import dev.usbharu.hideout.domain.model.hideout.entity.Visibility import dev.usbharu.hideout.domain.model.hideout.entity.Visibility
@ -19,12 +15,10 @@ import dev.usbharu.hideout.query.UserQueryService
import dev.usbharu.hideout.repository.PostRepository import dev.usbharu.hideout.repository.PostRepository
import dev.usbharu.hideout.service.ap.resource.APResourceResolveService import dev.usbharu.hideout.service.ap.resource.APResourceResolveService
import dev.usbharu.hideout.service.ap.resource.resolve import dev.usbharu.hideout.service.ap.resource.resolve
import dev.usbharu.hideout.service.core.Transaction
import dev.usbharu.hideout.service.job.JobQueueParentService import dev.usbharu.hideout.service.job.JobQueueParentService
import dev.usbharu.hideout.service.post.PostCreateInterceptor import dev.usbharu.hideout.service.post.PostCreateInterceptor
import dev.usbharu.hideout.service.post.PostService import dev.usbharu.hideout.service.post.PostService
import io.ktor.client.plugins.* import io.ktor.client.plugins.*
import kjob.core.job.JobProps
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -40,7 +34,7 @@ import java.time.Instant
interface APNoteService { interface APNoteService {
suspend fun createNote(post: Post) suspend fun createNote(post: Post)
suspend fun createNoteJob(props: JobProps<DeliverPostJob>)
@Cacheable("fetchNote") @Cacheable("fetchNote")
fun fetchNoteAsync(url: String, targetActor: String? = null): Deferred<Note> { fun fetchNoteAsync(url: String, targetActor: String? = null): Deferred<Note> {
@ -66,12 +60,9 @@ class APNoteServiceImpl(
private val postQueryService: PostQueryService, private val postQueryService: PostQueryService,
private val mediaQueryService: MediaQueryService, private val mediaQueryService: MediaQueryService,
@Qualifier("activitypub") private val objectMapper: ObjectMapper, @Qualifier("activitypub") private val objectMapper: ObjectMapper,
private val applicationConfig: ApplicationConfig,
private val postService: PostService, private val postService: PostService,
private val apResourceResolveService: APResourceResolveService, private val apResourceResolveService: APResourceResolveService,
private val apRequestService: APRequestService, private val postBuilder: Post.PostBuilder
private val postBuilder: Post.PostBuilder,
private val transaction: Transaction
) : APNoteService, PostCreateInterceptor { ) : APNoteService, PostCreateInterceptor {
@ -104,40 +95,7 @@ class APNoteServiceImpl(
logger.debug("SUCCESS Create Local Note ${post.url}") logger.debug("SUCCESS Create Local Note ${post.url}")
} }
override suspend fun createNoteJob(props: JobProps<DeliverPostJob>) {
val actor = props[DeliverPostJob.actor]
val postEntity = objectMapper.readValue<Post>(props[DeliverPostJob.post])
val mediaList =
objectMapper.readValue<List<dev.usbharu.hideout.domain.model.hideout.entity.Media>>(
props[DeliverPostJob.media]
)
val note = Note(
name = "Note",
id = postEntity.url,
attributedTo = actor,
content = postEntity.text,
published = Instant.ofEpochMilli(postEntity.createdAt).toString(),
to = listOf(public, "$actor/follower"),
attachment = mediaList.map { Document(mediaType = "image/jpeg", url = it.url) }
)
val inbox = props[DeliverPostJob.inbox]
logger.debug("createNoteJob: actor={}, note={}, inbox={}", actor, postEntity, inbox)
transaction.transaction {
val signer = userQueryService.findByUrl(actor)
apRequestService.apPost(
inbox,
Create(
name = "Create Note",
`object` = note,
actor = note.attributedTo,
id = "${applicationConfig.url}/create/note/${postEntity.id}"
),
signer
)
}
}
override suspend fun fetchNote(url: String, targetActor: String?): Note { override suspend fun fetchNote(url: String, targetActor: String?): Note {
logger.debug("START Fetch Note url: {}", url) logger.debug("START Fetch Note url: {}", url)

View File

@ -1,10 +1,6 @@
package dev.usbharu.hideout.service.ap package dev.usbharu.hideout.service.ap
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.config.ApplicationConfig
import dev.usbharu.hideout.domain.model.ap.Like
import dev.usbharu.hideout.domain.model.ap.Undo
import dev.usbharu.hideout.domain.model.hideout.entity.Reaction import dev.usbharu.hideout.domain.model.hideout.entity.Reaction
import dev.usbharu.hideout.domain.model.job.DeliverReactionJob import dev.usbharu.hideout.domain.model.job.DeliverReactionJob
import dev.usbharu.hideout.domain.model.job.DeliverRemoveReactionJob import dev.usbharu.hideout.domain.model.job.DeliverRemoveReactionJob
@ -12,16 +8,12 @@ import dev.usbharu.hideout.query.FollowerQueryService
import dev.usbharu.hideout.query.PostQueryService import dev.usbharu.hideout.query.PostQueryService
import dev.usbharu.hideout.query.UserQueryService import dev.usbharu.hideout.query.UserQueryService
import dev.usbharu.hideout.service.job.JobQueueParentService import dev.usbharu.hideout.service.job.JobQueueParentService
import kjob.core.job.JobProps
import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import java.time.Instant
interface APReactionService { interface APReactionService {
suspend fun reaction(like: Reaction) suspend fun reaction(like: Reaction)
suspend fun removeReaction(like: Reaction) suspend fun removeReaction(like: Reaction)
suspend fun reactionJob(props: JobProps<DeliverReactionJob>)
suspend fun removeReactionJob(props: JobProps<DeliverRemoveReactionJob>)
} }
@Service @Service
@ -30,9 +22,7 @@ class APReactionServiceImpl(
private val userQueryService: UserQueryService, private val userQueryService: UserQueryService,
private val followerQueryService: FollowerQueryService, private val followerQueryService: FollowerQueryService,
private val postQueryService: PostQueryService, private val postQueryService: PostQueryService,
@Qualifier("activitypub") private val objectMapper: ObjectMapper, @Qualifier("activitypub") private val objectMapper: ObjectMapper
private val applicationConfig: ApplicationConfig,
private val apRequestService: APRequestService
) : APReactionService { ) : APReactionService {
override suspend fun reaction(like: Reaction) { override suspend fun reaction(like: Reaction) {
val followers = followerQueryService.findFollowersById(like.userId) val followers = followerQueryService.findFollowersById(like.userId)
@ -64,46 +54,4 @@ class APReactionServiceImpl(
} }
} }
} }
override suspend fun reactionJob(props: JobProps<DeliverReactionJob>) {
val inbox = props[DeliverReactionJob.inbox]
val actor = props[DeliverReactionJob.actor]
val postUrl = props[DeliverReactionJob.postUrl]
val id = props[DeliverReactionJob.id]
val content = props[DeliverReactionJob.reaction]
val signer = userQueryService.findByUrl(actor)
apRequestService.apPost(
inbox,
Like(
name = "Like",
actor = actor,
`object` = postUrl,
id = "${applicationConfig.url}/like/note/$id",
content = content
),
signer
)
}
override suspend fun removeReactionJob(props: JobProps<DeliverRemoveReactionJob>) {
val inbox = props[DeliverRemoveReactionJob.inbox]
val actor = props[DeliverRemoveReactionJob.actor]
val like = objectMapper.readValue<Like>(props[DeliverRemoveReactionJob.like])
val signer = userQueryService.findByUrl(actor)
apRequestService.apPost(
inbox,
Undo(
name = "Undo Reaction",
actor = actor,
`object` = like,
id = "${applicationConfig.url}/undo/note/${like.id}",
published = Instant.now()
),
signer
)
}
} }

View File

@ -1,36 +1,24 @@
package dev.usbharu.hideout.service.ap package dev.usbharu.hideout.service.ap
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.domain.model.ActivityPubResponse import dev.usbharu.hideout.domain.model.ActivityPubResponse
import dev.usbharu.hideout.domain.model.ActivityPubStringResponse import dev.usbharu.hideout.domain.model.ActivityPubStringResponse
import dev.usbharu.hideout.domain.model.ap.Accept
import dev.usbharu.hideout.domain.model.ap.Follow import dev.usbharu.hideout.domain.model.ap.Follow
import dev.usbharu.hideout.domain.model.job.ReceiveFollowJob import dev.usbharu.hideout.domain.model.job.ReceiveFollowJob
import dev.usbharu.hideout.query.UserQueryService
import dev.usbharu.hideout.service.core.Transaction
import dev.usbharu.hideout.service.job.JobQueueParentService import dev.usbharu.hideout.service.job.JobQueueParentService
import dev.usbharu.hideout.service.user.UserService
import io.ktor.http.* import io.ktor.http.*
import kjob.core.job.JobProps
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
interface APReceiveFollowService { interface APReceiveFollowService {
suspend fun receiveFollow(follow: Follow): ActivityPubResponse suspend fun receiveFollow(follow: Follow): ActivityPubResponse
suspend fun receiveFollowJob(props: JobProps<ReceiveFollowJob>)
} }
@Service @Service
class APReceiveFollowServiceImpl( class APReceiveFollowServiceImpl(
private val jobQueueParentService: JobQueueParentService, private val jobQueueParentService: JobQueueParentService,
private val apUserService: APUserService, @Qualifier("activitypub") private val objectMapper: ObjectMapper
private val userService: UserService,
private val userQueryService: UserQueryService,
private val transaction: Transaction,
@Qualifier("activitypub") private val objectMapper: ObjectMapper,
private val apRequestService: APRequestService
) : APReceiveFollowService { ) : APReceiveFollowService {
override suspend fun receiveFollow(follow: Follow): ActivityPubResponse { override suspend fun receiveFollow(follow: Follow): ActivityPubResponse {
logger.info("FOLLOW from: {} to: {}", follow.actor, follow.`object`) logger.info("FOLLOW from: {} to: {}", follow.actor, follow.`object`)
@ -42,37 +30,6 @@ class APReceiveFollowServiceImpl(
return ActivityPubStringResponse(HttpStatusCode.OK, "{}", ContentType.Application.Json) return ActivityPubStringResponse(HttpStatusCode.OK, "{}", ContentType.Application.Json)
} }
override suspend fun receiveFollowJob(props: JobProps<ReceiveFollowJob>) {
transaction.transaction {
val actor = props[ReceiveFollowJob.actor]
val targetActor = props[ReceiveFollowJob.targetActor]
val person = apUserService.fetchPerson(actor, targetActor)
val follow = objectMapper.readValue<Follow>(props[ReceiveFollowJob.follow])
logger.info("START Follow from: {} to: {}", targetActor, actor)
val signer = userQueryService.findByUrl(targetActor)
val urlString = person.inbox ?: throw IllegalArgumentException("inbox is not found")
apRequestService.apPost(
url = urlString,
body = Accept(
name = "Follow",
`object` = follow,
actor = targetActor
),
signer = signer
)
val targetEntity = userQueryService.findByUrl(targetActor)
val followActorEntity =
userQueryService.findByUrl(follow.actor ?: throw java.lang.IllegalArgumentException("Actor is null"))
userService.followRequest(targetEntity.id, followActorEntity.id)
logger.info("SUCCESS Follow from: {} to: {}", targetActor, actor)
}
}
companion object { companion object {
private val logger = LoggerFactory.getLogger(APReceiveFollowServiceImpl::class.java) private val logger = LoggerFactory.getLogger(APReceiveFollowServiceImpl::class.java)
} }

View File

@ -7,6 +7,9 @@ import dev.usbharu.hideout.domain.model.ActivityPubResponse
import dev.usbharu.hideout.domain.model.ap.Follow import dev.usbharu.hideout.domain.model.ap.Follow
import dev.usbharu.hideout.domain.model.job.* import dev.usbharu.hideout.domain.model.job.*
import dev.usbharu.hideout.exception.JsonParseException import dev.usbharu.hideout.exception.JsonParseException
import dev.usbharu.hideout.service.ap.job.APReceiveFollowJobService
import dev.usbharu.hideout.service.ap.job.ApNoteJobService
import dev.usbharu.hideout.service.ap.job.ApReactionJobService
import kjob.core.dsl.JobContextWithProps import kjob.core.dsl.JobContextWithProps
import kjob.core.job.JobProps import kjob.core.job.JobProps
import org.slf4j.Logger import org.slf4j.Logger
@ -176,13 +179,14 @@ enum class ExtendedVocabulary {
@Service @Service
class APServiceImpl( class APServiceImpl(
private val apReceiveFollowService: APReceiveFollowService, private val apReceiveFollowService: APReceiveFollowService,
private val apNoteService: APNoteService,
private val apUndoService: APUndoService, private val apUndoService: APUndoService,
private val apAcceptService: APAcceptService, private val apAcceptService: APAcceptService,
private val apCreateService: APCreateService, private val apCreateService: APCreateService,
private val apLikeService: APLikeService, private val apLikeService: APLikeService,
private val apReactionService: APReactionService, @Qualifier("activitypub") private val objectMapper: ObjectMapper,
@Qualifier("activitypub") private val objectMapper: ObjectMapper private val apReceiveFollowJobService: APReceiveFollowJobService,
private val apNoteJobService: ApNoteJobService,
private val apReactionJobService: ApReactionJobService
) : APService { ) : APService {
val logger: Logger = LoggerFactory.getLogger(APServiceImpl::class.java) val logger: Logger = LoggerFactory.getLogger(APServiceImpl::class.java)
@ -237,14 +241,14 @@ class APServiceImpl(
// Springで作成されるプロキシの都合上パターンマッチングが壊れるので必須 // Springで作成されるプロキシの都合上パターンマッチングが壊れるので必須
when (hideoutJob) { when (hideoutJob) {
is ReceiveFollowJob -> { is ReceiveFollowJob -> {
apReceiveFollowService.receiveFollowJob( apReceiveFollowJobService.receiveFollowJob(
job.props as JobProps<ReceiveFollowJob> job.props as JobProps<ReceiveFollowJob>
) )
} }
is DeliverPostJob -> apNoteService.createNoteJob(job.props as JobProps<DeliverPostJob>) is DeliverPostJob -> apNoteJobService.createNoteJob(job.props as JobProps<DeliverPostJob>)
is DeliverReactionJob -> apReactionService.reactionJob(job.props as JobProps<DeliverReactionJob>) is DeliverReactionJob -> apReactionJobService.reactionJob(job.props as JobProps<DeliverReactionJob>)
is DeliverRemoveReactionJob -> apReactionService.removeReactionJob( is DeliverRemoveReactionJob -> apReactionJobService.removeReactionJob(
job.props as JobProps<DeliverRemoveReactionJob> job.props as JobProps<DeliverRemoveReactionJob>
) )

View File

@ -0,0 +1,8 @@
package dev.usbharu.hideout.service.ap.job
import dev.usbharu.hideout.domain.model.job.ReceiveFollowJob
import kjob.core.job.JobProps
interface APReceiveFollowJobService {
suspend fun receiveFollowJob(props: JobProps<ReceiveFollowJob>)
}

View File

@ -0,0 +1,61 @@
package dev.usbharu.hideout.service.ap.job
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.domain.model.ap.Accept
import dev.usbharu.hideout.domain.model.ap.Follow
import dev.usbharu.hideout.domain.model.job.ReceiveFollowJob
import dev.usbharu.hideout.query.UserQueryService
import dev.usbharu.hideout.service.ap.APRequestService
import dev.usbharu.hideout.service.ap.APUserService
import dev.usbharu.hideout.service.core.Transaction
import dev.usbharu.hideout.service.user.UserService
import kjob.core.job.JobProps
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.stereotype.Component
@Component
class APReceiveFollowJobServiceImpl(
private val apUserService: APUserService,
private val userQueryService: UserQueryService,
private val apRequestService: APRequestService,
private val userService: UserService,
@Qualifier("activitypub") private val objectMapper: ObjectMapper,
private val transaction: Transaction
) : APReceiveFollowJobService {
override suspend fun receiveFollowJob(props: JobProps<ReceiveFollowJob>) {
transaction.transaction {
val actor = props[ReceiveFollowJob.actor]
val targetActor = props[ReceiveFollowJob.targetActor]
val person = apUserService.fetchPerson(actor, targetActor)
val follow = objectMapper.readValue<Follow>(props[ReceiveFollowJob.follow])
logger.info("START Follow from: {} to: {}", targetActor, actor)
val signer = userQueryService.findByUrl(targetActor)
val urlString = person.inbox ?: throw IllegalArgumentException("inbox is not found")
apRequestService.apPost(
url = urlString,
body = Accept(
name = "Follow",
`object` = follow,
actor = targetActor
),
signer = signer
)
val targetEntity = userQueryService.findByUrl(targetActor)
val followActorEntity =
userQueryService.findByUrl(follow.actor ?: throw java.lang.IllegalArgumentException("Actor is null"))
userService.followRequest(targetEntity.id, followActorEntity.id)
logger.info("SUCCESS Follow from: {} to: {}", targetActor, actor)
}
}
companion object {
private val logger = LoggerFactory.getLogger(APReceiveFollowJobServiceImpl::class.java)
}
}

View File

@ -0,0 +1,8 @@
package dev.usbharu.hideout.service.ap.job
import dev.usbharu.hideout.domain.model.job.DeliverPostJob
import kjob.core.job.JobProps
interface ApNoteJobService {
suspend fun createNoteJob(props: JobProps<DeliverPostJob>)
}

View File

@ -0,0 +1,67 @@
package dev.usbharu.hideout.service.ap.job
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.config.ApplicationConfig
import dev.usbharu.hideout.domain.model.ap.Create
import dev.usbharu.hideout.domain.model.ap.Document
import dev.usbharu.hideout.domain.model.ap.Note
import dev.usbharu.hideout.domain.model.hideout.entity.Post
import dev.usbharu.hideout.domain.model.job.DeliverPostJob
import dev.usbharu.hideout.query.UserQueryService
import dev.usbharu.hideout.service.ap.APNoteServiceImpl
import dev.usbharu.hideout.service.ap.APRequestService
import dev.usbharu.hideout.service.core.Transaction
import kjob.core.job.JobProps
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.stereotype.Component
import java.time.Instant
@Component
class ApNoteJobServiceImpl(
private val userQueryService: UserQueryService,
private val apRequestService: APRequestService,
@Qualifier("activitypub") private val objectMapper: ObjectMapper,
private val transaction: Transaction,
private val applicationConfig: ApplicationConfig
) : ApNoteJobService {
override suspend fun createNoteJob(props: JobProps<DeliverPostJob>) {
val actor = props[DeliverPostJob.actor]
val postEntity = objectMapper.readValue<Post>(props[DeliverPostJob.post])
val mediaList =
objectMapper.readValue<List<dev.usbharu.hideout.domain.model.hideout.entity.Media>>(
props[DeliverPostJob.media]
)
val note = Note(
name = "Note",
id = postEntity.url,
attributedTo = actor,
content = postEntity.text,
published = Instant.ofEpochMilli(postEntity.createdAt).toString(),
to = listOf(APNoteServiceImpl.public, "$actor/follower"),
attachment = mediaList.map { Document(mediaType = "image/jpeg", url = it.url) }
)
val inbox = props[DeliverPostJob.inbox]
logger.debug("createNoteJob: actor={}, note={}, inbox={}", actor, postEntity, inbox)
transaction.transaction {
val signer = userQueryService.findByUrl(actor)
apRequestService.apPost(
inbox,
Create(
name = "Create Note",
`object` = note,
actor = note.attributedTo,
id = "${applicationConfig.url}/create/note/${postEntity.id}"
),
signer
)
}
}
companion object {
private val logger = LoggerFactory.getLogger(ApNoteJobServiceImpl::class.java)
}
}

View File

@ -0,0 +1,10 @@
package dev.usbharu.hideout.service.ap.job
import dev.usbharu.hideout.domain.model.job.DeliverReactionJob
import dev.usbharu.hideout.domain.model.job.DeliverRemoveReactionJob
import kjob.core.job.JobProps
interface ApReactionJobService {
suspend fun reactionJob(props: JobProps<DeliverReactionJob>)
suspend fun removeReactionJob(props: JobProps<DeliverRemoveReactionJob>)
}

View File

@ -0,0 +1,65 @@
package dev.usbharu.hideout.service.ap.job
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.config.ApplicationConfig
import dev.usbharu.hideout.domain.model.ap.Like
import dev.usbharu.hideout.domain.model.ap.Undo
import dev.usbharu.hideout.domain.model.job.DeliverReactionJob
import dev.usbharu.hideout.domain.model.job.DeliverRemoveReactionJob
import dev.usbharu.hideout.query.UserQueryService
import dev.usbharu.hideout.service.ap.APRequestService
import kjob.core.job.JobProps
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.stereotype.Service
import java.time.Instant
@Service
class ApReactionJobServiceImpl(
private val userQueryService: UserQueryService,
private val apRequestService: APRequestService,
private val applicationConfig: ApplicationConfig,
@Qualifier("activitypub") private val objectMapper: ObjectMapper
) : ApReactionJobService {
override suspend fun reactionJob(props: JobProps<DeliverReactionJob>) {
val inbox = props[DeliverReactionJob.inbox]
val actor = props[DeliverReactionJob.actor]
val postUrl = props[DeliverReactionJob.postUrl]
val id = props[DeliverReactionJob.id]
val content = props[DeliverReactionJob.reaction]
val signer = userQueryService.findByUrl(actor)
apRequestService.apPost(
inbox,
Like(
name = "Like",
actor = actor,
`object` = postUrl,
id = "${applicationConfig.url}/like/note/$id",
content = content
),
signer
)
}
override suspend fun removeReactionJob(props: JobProps<DeliverRemoveReactionJob>) {
val inbox = props[DeliverRemoveReactionJob.inbox]
val actor = props[DeliverRemoveReactionJob.actor]
val like = objectMapper.readValue<Like>(props[DeliverRemoveReactionJob.like])
val signer = userQueryService.findByUrl(actor)
apRequestService.apPost(
inbox,
Undo(
name = "Undo Reaction",
actor = actor,
`object` = like,
id = "${applicationConfig.url}/undo/note/${like.id}",
published = Instant.now()
),
signer
)
}
}

View File

@ -24,7 +24,6 @@ import org.mockito.Mockito.anyLong
import org.mockito.Mockito.eq import org.mockito.Mockito.eq
import org.mockito.kotlin.* import org.mockito.kotlin.*
import utils.JsonObjectMapper.objectMapper import utils.JsonObjectMapper.objectMapper
import utils.TestApplicationConfig.testApplicationConfig
import java.net.URL import java.net.URL
import java.time.Instant import java.time.Instant
import kotlin.test.assertEquals import kotlin.test.assertEquals
@ -104,11 +103,8 @@ class APNoteServiceImplTest {
postQueryService = mock(), postQueryService = mock(),
mediaQueryService = mediaQueryService, mediaQueryService = mediaQueryService,
objectMapper = objectMapper, objectMapper = objectMapper,
applicationConfig = testApplicationConfig,
postService = mock(), postService = mock(),
apResourceResolveService = mock(), apResourceResolveService = mock(),
apRequestService = mock(),
transaction = mock(),
postBuilder = postBuilder postBuilder = postBuilder
) )
val postEntity = postBuilder.of( val postEntity = postBuilder.of(
@ -147,11 +143,8 @@ class APNoteServiceImplTest {
postQueryService = mock(), postQueryService = mock(),
mediaQueryService = mediaQueryService, mediaQueryService = mediaQueryService,
objectMapper = objectMapper, objectMapper = objectMapper,
applicationConfig = testApplicationConfig,
postService = mock(), postService = mock(),
apResourceResolveService = mock(), apResourceResolveService = mock(),
apRequestService = mock(),
transaction = mock(),
postBuilder = postBuilder postBuilder = postBuilder
) )
activityPubNoteService.createNoteJob( activityPubNoteService.createNoteJob(

View File

@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers.anyString import org.mockito.ArgumentMatchers.anyString
import org.mockito.kotlin.* import org.mockito.kotlin.*
import utils.JsonObjectMapper.objectMapper import utils.JsonObjectMapper.objectMapper
import utils.TestTransaction
import java.net.URL import java.net.URL
import java.time.Instant import java.time.Instant
@ -42,12 +41,7 @@ class APReceiveFollowServiceImplTest {
val activityPubFollowService = val activityPubFollowService =
APReceiveFollowServiceImpl( APReceiveFollowServiceImpl(
jobQueueParentService, jobQueueParentService,
mock(), objectMapper
mock(),
mock(),
TestTransaction,
objectMapper,
mock()
) )
activityPubFollowService.receiveFollow( activityPubFollowService.receiveFollow(
Follow( Follow(
@ -153,12 +147,7 @@ class APReceiveFollowServiceImplTest {
val activityPubFollowService = val activityPubFollowService =
APReceiveFollowServiceImpl( APReceiveFollowServiceImpl(
mock(), mock(),
apUserService, objectMapper
userService,
userQueryService,
TestTransaction,
objectMapper,
mock()
) )
activityPubFollowService.receiveFollowJob( activityPubFollowService.receiveFollowJob(
JobProps( JobProps(