refactor: ActivityPubをAPに変更

This commit is contained in:
usbharu 2023-08-11 16:29:52 +09:00
parent f61c6c1713
commit 5f85a25daf
32 changed files with 137 additions and 134 deletions

View File

@ -15,8 +15,8 @@ import dev.usbharu.hideout.plugins.*
import dev.usbharu.hideout.query.FollowerQueryService import dev.usbharu.hideout.query.FollowerQueryService
import dev.usbharu.hideout.query.UserQueryService import dev.usbharu.hideout.query.UserQueryService
import dev.usbharu.hideout.routing.register import dev.usbharu.hideout.routing.register
import dev.usbharu.hideout.service.activitypub.ActivityPubService import dev.usbharu.hideout.service.ap.APService
import dev.usbharu.hideout.service.activitypub.ActivityPubUserService import dev.usbharu.hideout.service.ap.APUserService
import dev.usbharu.hideout.service.api.IPostApiService import dev.usbharu.hideout.service.api.IPostApiService
import dev.usbharu.hideout.service.api.IUserApiService import dev.usbharu.hideout.service.api.IUserApiService
import dev.usbharu.hideout.service.api.UserAuthApiService import dev.usbharu.hideout.service.api.UserAuthApiService
@ -109,9 +109,9 @@ fun Application.parent() {
) )
configureRouting( configureRouting(
httpSignatureVerifyService = inject<HttpSignatureVerifyService>().value, httpSignatureVerifyService = inject<HttpSignatureVerifyService>().value,
activityPubService = inject<ActivityPubService>().value, apService = inject<APService>().value,
userService = inject<IUserService>().value, userService = inject<IUserService>().value,
activityPubUserService = inject<ActivityPubUserService>().value, apUserService = inject<APUserService>().value,
postService = inject<IPostApiService>().value, postService = inject<IPostApiService>().value,
userApiService = inject<IUserApiService>().value, userApiService = inject<IUserApiService>().value,
userQueryService = inject<UserQueryService>().value, userQueryService = inject<UserQueryService>().value,
@ -128,28 +128,28 @@ fun Application.worker() {
connectionDatabase = inject<Database>().value connectionDatabase = inject<Database>().value
}.start() }.start()
val activityPubService = inject<ActivityPubService>().value val apService = inject<APService>().value
kJob.register(ReceiveFollowJob) { kJob.register(ReceiveFollowJob) {
execute { execute {
activityPubService.processActivity(this, it) apService.processActivity(this, it)
} }
} }
kJob.register(DeliverPostJob) { kJob.register(DeliverPostJob) {
execute { execute {
activityPubService.processActivity(this, it) apService.processActivity(this, it)
} }
} }
kJob.register(DeliverReactionJob) { kJob.register(DeliverReactionJob) {
execute { execute {
activityPubService.processActivity(this, it) apService.processActivity(this, it)
} }
} }
kJob.register(DeliverRemoveReactionJob) { kJob.register(DeliverRemoveReactionJob) {
execute { execute {
activityPubService.processActivity(this, it) apService.processActivity(this, it)
} }
} }
} }

View File

@ -4,7 +4,7 @@ import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonDeserializer import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.JsonNode
import dev.usbharu.hideout.service.activitypub.ExtendedActivityVocabulary import dev.usbharu.hideout.service.ap.ExtendedActivityVocabulary
class ObjectDeserializer : JsonDeserializer<Object>() { class ObjectDeserializer : JsonDeserializer<Object>() {
@Suppress("LongMethod", "CyclomaticComplexMethod") @Suppress("LongMethod", "CyclomaticComplexMethod")

View File

@ -9,8 +9,8 @@ import dev.usbharu.hideout.routing.api.internal.v1.auth
import dev.usbharu.hideout.routing.api.internal.v1.posts import dev.usbharu.hideout.routing.api.internal.v1.posts
import dev.usbharu.hideout.routing.api.internal.v1.users import dev.usbharu.hideout.routing.api.internal.v1.users
import dev.usbharu.hideout.routing.wellknown.webfinger import dev.usbharu.hideout.routing.wellknown.webfinger
import dev.usbharu.hideout.service.activitypub.ActivityPubService import dev.usbharu.hideout.service.ap.APService
import dev.usbharu.hideout.service.activitypub.ActivityPubUserService import dev.usbharu.hideout.service.ap.APUserService
import dev.usbharu.hideout.service.api.IPostApiService import dev.usbharu.hideout.service.api.IPostApiService
import dev.usbharu.hideout.service.api.IUserApiService import dev.usbharu.hideout.service.api.IUserApiService
import dev.usbharu.hideout.service.api.UserAuthApiService import dev.usbharu.hideout.service.api.UserAuthApiService
@ -25,9 +25,9 @@ import io.ktor.server.routing.*
@Suppress("LongParameterList") @Suppress("LongParameterList")
fun Application.configureRouting( fun Application.configureRouting(
httpSignatureVerifyService: HttpSignatureVerifyService, httpSignatureVerifyService: HttpSignatureVerifyService,
activityPubService: ActivityPubService, apService: APService,
userService: IUserService, userService: IUserService,
activityPubUserService: ActivityPubUserService, apUserService: APUserService,
postService: IPostApiService, postService: IPostApiService,
userApiService: IUserApiService, userApiService: IUserApiService,
userQueryService: UserQueryService, userQueryService: UserQueryService,
@ -38,9 +38,9 @@ fun Application.configureRouting(
) { ) {
install(AutoHeadResponse) install(AutoHeadResponse)
routing { routing {
inbox(httpSignatureVerifyService, activityPubService) inbox(httpSignatureVerifyService, apService)
outbox() outbox()
usersAP(activityPubUserService, userQueryService, followerQueryService, transaction) usersAP(apUserService, userQueryService, followerQueryService, transaction)
webfinger(webFingerApiService) webfinger(webFingerApiService)
route("/api/internal/v1") { route("/api/internal/v1") {
posts(postService) posts(postService)

View File

@ -13,7 +13,7 @@ import io.ktor.server.routing.*
fun Routing.inbox( fun Routing.inbox(
httpSignatureVerifyService: HttpSignatureVerifyService, httpSignatureVerifyService: HttpSignatureVerifyService,
activityPubService: dev.usbharu.hideout.service.activitypub.ActivityPubService apService: dev.usbharu.hideout.service.ap.APService
) { ) {
route("/inbox") { route("/inbox") {
get { get {
@ -25,9 +25,9 @@ fun Routing.inbox(
} }
val json = call.receiveText() val json = call.receiveText()
call.application.log.trace("Received: $json") call.application.log.trace("Received: $json")
val activityTypes = activityPubService.parseActivity(json) val activityTypes = apService.parseActivity(json)
call.application.log.debug("ActivityTypes: ${activityTypes.name}") call.application.log.debug("ActivityTypes: ${activityTypes.name}")
val response = activityPubService.processActivity(json, activityTypes) val response = apService.processActivity(json, activityTypes)
when (response) { when (response) {
is ActivityPubObjectResponse -> call.respond( is ActivityPubObjectResponse -> call.respond(
response.httpStatusCode, response.httpStatusCode,
@ -54,9 +54,9 @@ fun Routing.inbox(
} }
val json = call.receiveText() val json = call.receiveText()
call.application.log.trace("Received: $json") call.application.log.trace("Received: $json")
val activityTypes = activityPubService.parseActivity(json) val activityTypes = apService.parseActivity(json)
call.application.log.debug("ActivityTypes: ${activityTypes.name}") call.application.log.debug("ActivityTypes: ${activityTypes.name}")
val response = activityPubService.processActivity(json, activityTypes) val response = apService.processActivity(json, activityTypes)
when (response) { when (response) {
is ActivityPubObjectResponse -> call.respond( is ActivityPubObjectResponse -> call.respond(
response.httpStatusCode, response.httpStatusCode,

View File

@ -5,7 +5,7 @@ import dev.usbharu.hideout.exception.ParameterNotExistException
import dev.usbharu.hideout.plugins.respondAp import dev.usbharu.hideout.plugins.respondAp
import dev.usbharu.hideout.query.FollowerQueryService import dev.usbharu.hideout.query.FollowerQueryService
import dev.usbharu.hideout.query.UserQueryService import dev.usbharu.hideout.query.UserQueryService
import dev.usbharu.hideout.service.activitypub.ActivityPubUserService import dev.usbharu.hideout.service.ap.APUserService
import dev.usbharu.hideout.service.core.Transaction import dev.usbharu.hideout.service.core.Transaction
import dev.usbharu.hideout.util.HttpUtil.Activity import dev.usbharu.hideout.util.HttpUtil.Activity
import dev.usbharu.hideout.util.HttpUtil.JsonLd import dev.usbharu.hideout.util.HttpUtil.JsonLd
@ -16,7 +16,7 @@ import io.ktor.server.response.*
import io.ktor.server.routing.* import io.ktor.server.routing.*
fun Routing.usersAP( fun Routing.usersAP(
activityPubUserService: ActivityPubUserService, apUserService: APUserService,
userQueryService: UserQueryService, userQueryService: UserQueryService,
followerQueryService: FollowerQueryService, followerQueryService: FollowerQueryService,
transaction: Transaction transaction: Transaction
@ -27,7 +27,7 @@ fun Routing.usersAP(
call.application.log.debug("Authorization: ${call.request.header("Authorization")}") call.application.log.debug("Authorization: ${call.request.header("Authorization")}")
val name = val name =
call.parameters["name"] ?: throw ParameterNotExistException("Parameter(name='name') does not exist.") call.parameters["name"] ?: throw ParameterNotExistException("Parameter(name='name') does not exist.")
val person = activityPubUserService.getPersonByName(name) val person = apUserService.getPersonByName(name)
return@handle call.respondAp( return@handle call.respondAp(
person, person,
HttpStatusCode.OK HttpStatusCode.OK

View File

@ -1,8 +1,8 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import dev.usbharu.hideout.domain.model.ActivityPubResponse import dev.usbharu.hideout.domain.model.ActivityPubResponse
import dev.usbharu.hideout.domain.model.ap.Accept import dev.usbharu.hideout.domain.model.ap.Accept
interface ActivityPubAcceptService { interface APAcceptService {
suspend fun receiveAccept(accept: Accept): ActivityPubResponse suspend fun receiveAccept(accept: Accept): ActivityPubResponse
} }

View File

@ -1,4 +1,4 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
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
@ -11,10 +11,10 @@ import io.ktor.http.*
import org.koin.core.annotation.Single import org.koin.core.annotation.Single
@Single @Single
class ActivityPubAcceptServiceImpl( class APAcceptServiceImpl(
private val userService: IUserService, private val userService: IUserService,
private val userQueryService: UserQueryService private val userQueryService: UserQueryService
) : ActivityPubAcceptService { ) : APAcceptService {
override suspend fun receiveAccept(accept: Accept): ActivityPubResponse { override suspend fun receiveAccept(accept: Accept): ActivityPubResponse {
val value = accept.`object` ?: throw IllegalActivityPubObjectException("object is null") val value = accept.`object` ?: throw IllegalActivityPubObjectException("object is null")
if (value.type.contains("Follow").not()) { if (value.type.contains("Follow").not()) {

View File

@ -1,8 +1,8 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import dev.usbharu.hideout.domain.model.ActivityPubResponse import dev.usbharu.hideout.domain.model.ActivityPubResponse
import dev.usbharu.hideout.domain.model.ap.Create import dev.usbharu.hideout.domain.model.ap.Create
interface ActivityPubCreateService { interface APCreateService {
suspend fun receiveCreate(create: Create): ActivityPubResponse suspend fun receiveCreate(create: Create): ActivityPubResponse
} }

View File

@ -1,4 +1,4 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
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
@ -10,10 +10,10 @@ import io.ktor.http.*
import org.koin.core.annotation.Single import org.koin.core.annotation.Single
@Single @Single
class ActivityPubCreateServiceImpl( class APCreateServiceImpl(
private val activityPubNoteService: ActivityPubNoteService, private val apNoteService: APNoteService,
private val transaction: Transaction private val transaction: Transaction
) : ActivityPubCreateService { ) : APCreateService {
override suspend fun receiveCreate(create: Create): ActivityPubResponse { override suspend fun receiveCreate(create: Create): ActivityPubResponse {
val value = create.`object` ?: throw IllegalActivityPubObjectException("object is null") val value = create.`object` ?: throw IllegalActivityPubObjectException("object is null")
if (value.type.contains("Note").not()) { if (value.type.contains("Note").not()) {
@ -22,7 +22,7 @@ class ActivityPubCreateServiceImpl(
return transaction.transaction { return transaction.transaction {
val note = value as Note val note = value as Note
activityPubNoteService.fetchNote(note) apNoteService.fetchNote(note)
ActivityPubStringResponse(HttpStatusCode.OK, "Created") ActivityPubStringResponse(HttpStatusCode.OK, "Created")
} }
} }

View File

@ -1,8 +1,8 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import dev.usbharu.hideout.domain.model.ActivityPubResponse import dev.usbharu.hideout.domain.model.ActivityPubResponse
import dev.usbharu.hideout.domain.model.ap.Like import dev.usbharu.hideout.domain.model.ap.Like
interface ActivityPubLikeService { interface APLikeService {
suspend fun receiveLike(like: Like): ActivityPubResponse suspend fun receiveLike(like: Like): ActivityPubResponse
} }

View File

@ -1,4 +1,4 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
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
@ -12,21 +12,21 @@ import io.ktor.http.*
import org.koin.core.annotation.Single import org.koin.core.annotation.Single
@Single @Single
class ActivityPubLikeServiceImpl( class APLikeServiceImpl(
private val reactionService: IReactionService, private val reactionService: IReactionService,
private val activityPubUserService: ActivityPubUserService, private val apUserService: APUserService,
private val activityPubNoteService: ActivityPubNoteService, private val apNoteService: APNoteService,
private val userQueryService: UserQueryService, private val userQueryService: UserQueryService,
private val postQueryService: PostQueryService, private val postQueryService: PostQueryService,
private val transaction: Transaction private val transaction: Transaction
) : ActivityPubLikeService { ) : APLikeService {
override suspend fun receiveLike(like: Like): ActivityPubResponse { override suspend fun receiveLike(like: Like): ActivityPubResponse {
val actor = like.actor ?: throw IllegalActivityPubObjectException("actor is null") val actor = like.actor ?: throw IllegalActivityPubObjectException("actor is null")
val content = like.content ?: throw IllegalActivityPubObjectException("content is null") val content = like.content ?: throw IllegalActivityPubObjectException("content is null")
like.`object` ?: throw IllegalActivityPubObjectException("object is null") like.`object` ?: throw IllegalActivityPubObjectException("object is null")
transaction.transaction { transaction.transaction {
val person = activityPubUserService.fetchPerson(actor) val person = apUserService.fetchPerson(actor)
activityPubNoteService.fetchNote(like.`object`!!) apNoteService.fetchNote(like.`object`!!)
val user = userQueryService.findByUrl( val user = userQueryService.findByUrl(
person.url person.url

View File

@ -1,11 +1,11 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
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.job.DeliverPostJob import dev.usbharu.hideout.domain.model.job.DeliverPostJob
import kjob.core.job.JobProps import kjob.core.job.JobProps
interface ActivityPubNoteService { interface APNoteService {
suspend fun createNote(post: Post) suspend fun createNote(post: Post)
suspend fun createNoteJob(props: JobProps<DeliverPostJob>) suspend fun createNoteJob(props: JobProps<DeliverPostJob>)

View File

@ -1,4 +1,4 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.config.Config
@ -23,15 +23,15 @@ import org.slf4j.LoggerFactory
import java.time.Instant import java.time.Instant
@Single @Single
class ActivityPubNoteServiceImpl( class APNoteServiceImpl(
private val httpClient: HttpClient, private val httpClient: HttpClient,
private val jobQueueParentService: JobQueueParentService, private val jobQueueParentService: JobQueueParentService,
private val postRepository: IPostRepository, private val postRepository: IPostRepository,
private val activityPubUserService: ActivityPubUserService, private val apUserService: APUserService,
private val userQueryService: UserQueryService, private val userQueryService: UserQueryService,
private val followerQueryService: FollowerQueryService, private val followerQueryService: FollowerQueryService,
private val postQueryService: PostQueryService private val postQueryService: PostQueryService
) : ActivityPubNoteService { ) : APNoteService {
private val logger = LoggerFactory.getLogger(this::class.java) private val logger = LoggerFactory.getLogger(this::class.java)
@ -75,9 +75,12 @@ class ActivityPubNoteServiceImpl(
override suspend fun fetchNote(url: String, targetActor: String?): Note { override suspend fun fetchNote(url: String, targetActor: String?): Note {
val post = postQueryService.findByUrl(url) val post = postQueryService.findByUrl(url)
if (post != null) { try {
return postToNote(post) return postToNote(post)
} catch (_: NoSuchElementException) {
} catch (_: IllegalArgumentException) {
} }
val response = httpClient.getAp( val response = httpClient.getAp(
url, url,
targetActor?.let { "$targetActor#pubkey" } targetActor?.let { "$targetActor#pubkey" }
@ -118,7 +121,7 @@ class ActivityPubNoteServiceImpl(
} }
private suspend fun internalNote(note: Note, targetActor: String?, url: String): Note { private suspend fun internalNote(note: Note, targetActor: String?, url: String): Note {
val person = activityPubUserService.fetchPerson( val person = apUserService.fetchPerson(
note.attributedTo ?: throw IllegalActivityPubObjectException("note.attributedTo is null"), note.attributedTo ?: throw IllegalActivityPubObjectException("note.attributedTo is null"),
targetActor targetActor
) )

View File

@ -1,11 +1,11 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
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
import kjob.core.job.JobProps import kjob.core.job.JobProps
interface ActivityPubReactionService { 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 reactionJob(props: JobProps<DeliverReactionJob>)

View File

@ -1,4 +1,4 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.config.Config
@ -19,14 +19,14 @@ import org.koin.core.annotation.Single
import java.time.Instant import java.time.Instant
@Single @Single
class ActivityPubReactionServiceImpl( class APReactionServiceImpl(
private val jobQueueParentService: JobQueueParentService, private val jobQueueParentService: JobQueueParentService,
private val iPostRepository: IPostRepository, private val iPostRepository: IPostRepository,
private val httpClient: HttpClient, private val httpClient: HttpClient,
private val userQueryService: UserQueryService, private val userQueryService: UserQueryService,
private val followerQueryService: FollowerQueryService, private val followerQueryService: FollowerQueryService,
private val postQueryService: PostQueryService private val postQueryService: PostQueryService
) : ActivityPubReactionService { ) : 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)
val user = userQueryService.findById(like.userId) val user = userQueryService.findById(like.userId)

View File

@ -1,11 +1,11 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import dev.usbharu.hideout.domain.model.ActivityPubResponse 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.ReceiveFollowJob import dev.usbharu.hideout.domain.model.job.ReceiveFollowJob
import kjob.core.job.JobProps import kjob.core.job.JobProps
interface ActivityPubReceiveFollowService { interface APReceiveFollowService {
suspend fun receiveFollow(follow: Follow): ActivityPubResponse suspend fun receiveFollow(follow: Follow): ActivityPubResponse
suspend fun receiveFollowJob(props: JobProps<ReceiveFollowJob>) suspend fun receiveFollowJob(props: JobProps<ReceiveFollowJob>)
} }

View File

@ -1,4 +1,4 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.config.Config
@ -18,14 +18,14 @@ import kjob.core.job.JobProps
import org.koin.core.annotation.Single import org.koin.core.annotation.Single
@Single @Single
class ActivityPubReceiveFollowServiceImpl( class APReceiveFollowServiceImpl(
private val jobQueueParentService: JobQueueParentService, private val jobQueueParentService: JobQueueParentService,
private val activityPubUserService: ActivityPubUserService, private val apUserService: APUserService,
private val userService: IUserService, private val userService: IUserService,
private val httpClient: HttpClient, private val httpClient: HttpClient,
private val userQueryService: UserQueryService, private val userQueryService: UserQueryService,
private val transaction: Transaction private val transaction: Transaction
) : ActivityPubReceiveFollowService { ) : APReceiveFollowService {
override suspend fun receiveFollow(follow: Follow): ActivityPubResponse { override suspend fun receiveFollow(follow: Follow): ActivityPubResponse {
// TODO: Verify HTTP Signature // TODO: Verify HTTP Signature
jobQueueParentService.schedule(ReceiveFollowJob) { jobQueueParentService.schedule(ReceiveFollowJob) {
@ -40,7 +40,7 @@ class ActivityPubReceiveFollowServiceImpl(
transaction.transaction { transaction.transaction {
val actor = props[ReceiveFollowJob.actor] val actor = props[ReceiveFollowJob.actor]
val targetActor = props[ReceiveFollowJob.targetActor] val targetActor = props[ReceiveFollowJob.targetActor]
val person = activityPubUserService.fetchPerson(actor, targetActor) val person = apUserService.fetchPerson(actor, targetActor)
val follow = Config.configData.objectMapper.readValue<Follow>(props[ReceiveFollowJob.follow]) val follow = Config.configData.objectMapper.readValue<Follow>(props[ReceiveFollowJob.follow])
httpClient.postAp( httpClient.postAp(
urlString = person.inbox ?: throw IllegalArgumentException("inbox is not found"), urlString = person.inbox ?: throw IllegalArgumentException("inbox is not found"),

View File

@ -1,7 +1,7 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import dev.usbharu.hideout.domain.model.hideout.dto.SendFollowDto import dev.usbharu.hideout.domain.model.hideout.dto.SendFollowDto
interface ActivityPubSendFollowService { interface APSendFollowService {
suspend fun sendFollow(sendFollowDto: SendFollowDto) suspend fun sendFollow(sendFollowDto: SendFollowDto)
} }

View File

@ -1,4 +1,4 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import dev.usbharu.hideout.domain.model.ap.Follow import dev.usbharu.hideout.domain.model.ap.Follow
import dev.usbharu.hideout.domain.model.hideout.dto.SendFollowDto import dev.usbharu.hideout.domain.model.hideout.dto.SendFollowDto
@ -7,7 +7,7 @@ import io.ktor.client.*
import org.koin.core.annotation.Single import org.koin.core.annotation.Single
@Single @Single
class ActivityPubSendFollowServiceImpl(private val httpClient: HttpClient) : ActivityPubSendFollowService { class APSendFollowServiceImpl(private val httpClient: HttpClient) : APSendFollowService {
override suspend fun sendFollow(sendFollowDto: SendFollowDto) { override suspend fun sendFollow(sendFollowDto: SendFollowDto) {
val follow = Follow( val follow = Follow(
name = "Follow", name = "Follow",

View File

@ -1,10 +1,10 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import dev.usbharu.hideout.domain.model.ActivityPubResponse import dev.usbharu.hideout.domain.model.ActivityPubResponse
import dev.usbharu.hideout.domain.model.job.HideoutJob import dev.usbharu.hideout.domain.model.job.HideoutJob
import kjob.core.dsl.JobContextWithProps import kjob.core.dsl.JobContextWithProps
interface ActivityPubService { interface APService {
fun parseActivity(json: String): ActivityType fun parseActivity(json: String): ActivityType
suspend fun processActivity(json: String, type: ActivityType): ActivityPubResponse? suspend fun processActivity(json: String, type: ActivityType): ActivityPubResponse?

View File

@ -1,4 +1,4 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
@ -14,15 +14,15 @@ import org.slf4j.Logger
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
@Single @Single
class ActivityPubServiceImpl( class APServiceImpl(
private val activityPubReceiveFollowService: ActivityPubReceiveFollowService, private val apReceiveFollowService: APReceiveFollowService,
private val activityPubNoteService: ActivityPubNoteService, private val apNoteService: APNoteService,
private val activityPubUndoService: ActivityPubUndoService, private val apUndoService: APUndoService,
private val activityPubAcceptService: ActivityPubAcceptService, private val apAcceptService: APAcceptService,
private val activityPubCreateService: ActivityPubCreateService, private val apCreateService: APCreateService,
private val activityPubLikeService: ActivityPubLikeService, private val apLikeService: APLikeService,
private val activityPubReactionService: ActivityPubReactionService private val apReactionService: APReactionService
) : ActivityPubService { ) : APService {
val logger: Logger = LoggerFactory.getLogger(this::class.java) val logger: Logger = LoggerFactory.getLogger(this::class.java)
override fun parseActivity(json: String): ActivityType { override fun parseActivity(json: String): ActivityType {
@ -44,17 +44,17 @@ class ActivityPubServiceImpl(
override suspend fun processActivity(json: String, type: ActivityType): ActivityPubResponse { override suspend fun processActivity(json: String, type: ActivityType): ActivityPubResponse {
logger.debug("proccess activity: {}", type) logger.debug("proccess activity: {}", type)
return when (type) { return when (type) {
ActivityType.Accept -> activityPubAcceptService.receiveAccept(configData.objectMapper.readValue(json)) ActivityType.Accept -> apAcceptService.receiveAccept(configData.objectMapper.readValue(json))
ActivityType.Follow -> activityPubReceiveFollowService.receiveFollow( ActivityType.Follow -> apReceiveFollowService.receiveFollow(
configData.objectMapper.readValue( configData.objectMapper.readValue(
json, json,
Follow::class.java Follow::class.java
) )
) )
ActivityType.Create -> activityPubCreateService.receiveCreate(configData.objectMapper.readValue(json)) ActivityType.Create -> apCreateService.receiveCreate(configData.objectMapper.readValue(json))
ActivityType.Like -> activityPubLikeService.receiveLike(configData.objectMapper.readValue(json)) ActivityType.Like -> apLikeService.receiveLike(configData.objectMapper.readValue(json))
ActivityType.Undo -> activityPubUndoService.receiveUndo(configData.objectMapper.readValue(json)) ActivityType.Undo -> apUndoService.receiveUndo(configData.objectMapper.readValue(json))
else -> { else -> {
throw IllegalArgumentException("$type is not supported.") throw IllegalArgumentException("$type is not supported.")
@ -65,13 +65,13 @@ class ActivityPubServiceImpl(
override suspend fun <T : HideoutJob> processActivity(job: JobContextWithProps<T>, hideoutJob: HideoutJob) { override suspend fun <T : HideoutJob> processActivity(job: JobContextWithProps<T>, hideoutJob: HideoutJob) {
logger.debug("processActivity: ${hideoutJob.name}") logger.debug("processActivity: ${hideoutJob.name}")
when (hideoutJob) { when (hideoutJob) {
ReceiveFollowJob -> activityPubReceiveFollowService.receiveFollowJob( ReceiveFollowJob -> apReceiveFollowService.receiveFollowJob(
job.props as JobProps<ReceiveFollowJob> job.props as JobProps<ReceiveFollowJob>
) )
DeliverPostJob -> activityPubNoteService.createNoteJob(job.props as JobProps<DeliverPostJob>) DeliverPostJob -> apNoteService.createNoteJob(job.props as JobProps<DeliverPostJob>)
DeliverReactionJob -> activityPubReactionService.reactionJob(job.props as JobProps<DeliverReactionJob>) DeliverReactionJob -> apReactionService.reactionJob(job.props as JobProps<DeliverReactionJob>)
DeliverRemoveReactionJob -> activityPubReactionService.removeReactionJob( DeliverRemoveReactionJob -> apReactionService.removeReactionJob(
job.props as JobProps<DeliverRemoveReactionJob> job.props as JobProps<DeliverRemoveReactionJob>
) )
} }

View File

@ -1,8 +1,8 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import dev.usbharu.hideout.domain.model.ActivityPubResponse import dev.usbharu.hideout.domain.model.ActivityPubResponse
import dev.usbharu.hideout.domain.model.ap.Undo import dev.usbharu.hideout.domain.model.ap.Undo
interface ActivityPubUndoService { interface APUndoService {
suspend fun receiveUndo(undo: Undo): ActivityPubResponse suspend fun receiveUndo(undo: Undo): ActivityPubResponse
} }

View File

@ -1,4 +1,4 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
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
@ -12,12 +12,12 @@ import org.koin.core.annotation.Single
@Single @Single
@Suppress("UnsafeCallOnNullableType") @Suppress("UnsafeCallOnNullableType")
class ActivityPubUndoServiceImpl( class APUndoServiceImpl(
private val userService: IUserService, private val userService: IUserService,
private val activityPubUserService: ActivityPubUserService, private val apUserService: APUserService,
private val userQueryService: UserQueryService, private val userQueryService: UserQueryService,
private val transaction: Transaction private val transaction: Transaction
) : ActivityPubUndoService { ) : APUndoService {
override suspend fun receiveUndo(undo: Undo): ActivityPubResponse { override suspend fun receiveUndo(undo: Undo): ActivityPubResponse {
if (undo.actor == null) { if (undo.actor == null) {
return ActivityPubStringResponse(HttpStatusCode.BadRequest, "actor is null") return ActivityPubStringResponse(HttpStatusCode.BadRequest, "actor is null")
@ -36,7 +36,7 @@ class ActivityPubUndoServiceImpl(
return ActivityPubStringResponse(HttpStatusCode.BadRequest, "object.object is null") return ActivityPubStringResponse(HttpStatusCode.BadRequest, "object.object is null")
} }
transaction.transaction { transaction.transaction {
activityPubUserService.fetchPerson(undo.actor!!, follow.`object`) apUserService.fetchPerson(undo.actor!!, follow.`object`)
val follower = userQueryService.findByUrl(undo.actor!!) val follower = userQueryService.findByUrl(undo.actor!!)
val target = userQueryService.findByUrl(follow.`object`!!) val target = userQueryService.findByUrl(follow.`object`!!)
userService.unfollow(target.id, follower.id) userService.unfollow(target.id, follower.id)

View File

@ -1,8 +1,8 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import dev.usbharu.hideout.domain.model.ap.Person import dev.usbharu.hideout.domain.model.ap.Person
interface ActivityPubUserService { interface APUserService {
suspend fun getPersonByName(name: String): Person suspend fun getPersonByName(name: String): Person
/** /**

View File

@ -1,4 +1,4 @@
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.config.Config
@ -19,13 +19,13 @@ import io.ktor.http.*
import org.koin.core.annotation.Single import org.koin.core.annotation.Single
@Single @Single
class ActivityPubUserServiceImpl( class APUserServiceImpl(
private val userService: IUserService, private val userService: IUserService,
private val httpClient: HttpClient, private val httpClient: HttpClient,
private val userQueryService: UserQueryService, private val userQueryService: UserQueryService,
private val transaction: Transaction private val transaction: Transaction
) : ) :
ActivityPubUserService { APUserService {
override suspend fun getPersonByName(name: String): Person { override suspend fun getPersonByName(name: String): Person {
val userEntity = transaction.transaction { val userEntity = transaction.transaction {

View File

@ -5,7 +5,7 @@ import dev.usbharu.hideout.domain.model.hideout.entity.Post
import dev.usbharu.hideout.exception.UserNotFoundException import dev.usbharu.hideout.exception.UserNotFoundException
import dev.usbharu.hideout.repository.IPostRepository import dev.usbharu.hideout.repository.IPostRepository
import dev.usbharu.hideout.repository.IUserRepository import dev.usbharu.hideout.repository.IUserRepository
import dev.usbharu.hideout.service.activitypub.ActivityPubNoteService import dev.usbharu.hideout.service.ap.APNoteService
import org.koin.core.annotation.Single import org.koin.core.annotation.Single
import java.time.Instant import java.time.Instant
@ -13,7 +13,7 @@ import java.time.Instant
class PostServiceImpl( class PostServiceImpl(
private val postRepository: IPostRepository, private val postRepository: IPostRepository,
private val userRepository: IUserRepository, private val userRepository: IUserRepository,
private val activityPubNoteService: ActivityPubNoteService private val apNoteService: APNoteService
) : IPostService { ) : IPostService {
override suspend fun createLocal(post: PostCreateDto): Post { override suspend fun createLocal(post: PostCreateDto): Post {
val user = userRepository.findById(post.userId) ?: throw UserNotFoundException("${post.userId} was not found") val user = userRepository.findById(post.userId) ?: throw UserNotFoundException("${post.userId} was not found")
@ -29,7 +29,7 @@ class PostServiceImpl(
repostId = null, repostId = null,
replyId = null replyId = null
) )
activityPubNoteService.createNote(createPost) apNoteService.createNote(createPost)
return internalCreate(createPost) return internalCreate(createPost)
} }

View File

@ -3,13 +3,13 @@ package dev.usbharu.hideout.service.reaction
import dev.usbharu.hideout.domain.model.hideout.entity.Reaction import dev.usbharu.hideout.domain.model.hideout.entity.Reaction
import dev.usbharu.hideout.query.ReactionQueryService import dev.usbharu.hideout.query.ReactionQueryService
import dev.usbharu.hideout.repository.ReactionRepository import dev.usbharu.hideout.repository.ReactionRepository
import dev.usbharu.hideout.service.activitypub.ActivityPubReactionService import dev.usbharu.hideout.service.ap.APReactionService
import org.koin.core.annotation.Single import org.koin.core.annotation.Single
@Single @Single
class ReactionServiceImpl( class ReactionServiceImpl(
private val reactionRepository: ReactionRepository, private val reactionRepository: ReactionRepository,
private val activityPubReactionService: ActivityPubReactionService, private val apReactionService: APReactionService,
private val reactionQueryService: ReactionQueryService private val reactionQueryService: ReactionQueryService
) : IReactionService { ) : IReactionService {
override suspend fun receiveReaction(name: String, domain: String, userId: Long, postId: Long) { override suspend fun receiveReaction(name: String, domain: String, userId: Long, postId: Long) {
@ -27,7 +27,7 @@ class ReactionServiceImpl(
} else { } else {
val reaction = Reaction(reactionRepository.generateId(), 0, postId, userId) val reaction = Reaction(reactionRepository.generateId(), 0, postId, userId)
reactionRepository.save(reaction) reactionRepository.save(reaction)
activityPubReactionService.reaction(reaction) apReactionService.reaction(reaction)
} }
} }

View File

@ -9,7 +9,7 @@ import dev.usbharu.hideout.exception.UserNotFoundException
import dev.usbharu.hideout.query.FollowerQueryService import dev.usbharu.hideout.query.FollowerQueryService
import dev.usbharu.hideout.query.UserQueryService import dev.usbharu.hideout.query.UserQueryService
import dev.usbharu.hideout.repository.IUserRepository import dev.usbharu.hideout.repository.IUserRepository
import dev.usbharu.hideout.service.activitypub.ActivityPubSendFollowService import dev.usbharu.hideout.service.ap.APSendFollowService
import org.koin.core.annotation.Single import org.koin.core.annotation.Single
import java.time.Instant import java.time.Instant
@ -17,7 +17,7 @@ import java.time.Instant
class UserService( class UserService(
private val userRepository: IUserRepository, private val userRepository: IUserRepository,
private val userAuthService: IUserAuthService, private val userAuthService: IUserAuthService,
private val activityPubSendFollowService: ActivityPubSendFollowService, private val apSendFollowService: APSendFollowService,
private val userQueryService: UserQueryService, private val userQueryService: UserQueryService,
private val followerQueryService: FollowerQueryService private val followerQueryService: FollowerQueryService
) : ) :
@ -77,7 +77,7 @@ class UserService(
if (userRepository.findFollowRequestsById(id, followerId)) { if (userRepository.findFollowRequestsById(id, followerId)) {
// do-nothing // do-nothing
} else { } else {
activityPubSendFollowService.sendFollow(SendFollowDto(follower, user)) apSendFollowService.sendFollow(SendFollowDto(follower, user))
} }
false false
} }

View File

@ -3,8 +3,8 @@ package dev.usbharu.hideout.routing.activitypub
import dev.usbharu.hideout.exception.JsonParseException import dev.usbharu.hideout.exception.JsonParseException
import dev.usbharu.hideout.plugins.configureSerialization import dev.usbharu.hideout.plugins.configureSerialization
import dev.usbharu.hideout.plugins.configureStatusPages import dev.usbharu.hideout.plugins.configureStatusPages
import dev.usbharu.hideout.service.activitypub.ActivityPubService import dev.usbharu.hideout.service.ap.APService
import dev.usbharu.hideout.service.activitypub.ActivityPubUserService import dev.usbharu.hideout.service.ap.APUserService
import dev.usbharu.hideout.service.auth.HttpSignatureVerifyService import dev.usbharu.hideout.service.auth.HttpSignatureVerifyService
import dev.usbharu.hideout.service.user.IUserService import dev.usbharu.hideout.service.user.IUserService
import io.ktor.client.request.* import io.ktor.client.request.*
@ -44,16 +44,16 @@ class InboxRoutingKtTest {
val httpSignatureVerifyService = mock<HttpSignatureVerifyService> { val httpSignatureVerifyService = mock<HttpSignatureVerifyService> {
on { verify(any()) } doReturn true on { verify(any()) } doReturn true
} }
val activityPubService = mock<ActivityPubService> { val apService = mock<APService> {
on { parseActivity(any()) } doThrow JsonParseException() on { parseActivity(any()) } doThrow JsonParseException()
} }
mock<IUserService>() mock<IUserService>()
mock<ActivityPubUserService>() mock<APUserService>()
application { application {
configureStatusPages() configureStatusPages()
configureSerialization() configureSerialization()
routing { routing {
inbox(httpSignatureVerifyService, activityPubService) inbox(httpSignatureVerifyService, apService)
} }
} }
client.post("/inbox").let { client.post("/inbox").let {
@ -85,16 +85,16 @@ class InboxRoutingKtTest {
val httpSignatureVerifyService = mock<HttpSignatureVerifyService> { val httpSignatureVerifyService = mock<HttpSignatureVerifyService> {
on { verify(any()) } doReturn true on { verify(any()) } doReturn true
} }
val activityPubService = mock<ActivityPubService> { val apService = mock<APService> {
on { parseActivity(any()) } doThrow JsonParseException() on { parseActivity(any()) } doThrow JsonParseException()
} }
mock<IUserService>() mock<IUserService>()
mock<ActivityPubUserService>() mock<APUserService>()
application { application {
configureStatusPages() configureStatusPages()
configureSerialization() configureSerialization()
routing { routing {
inbox(httpSignatureVerifyService, activityPubService) inbox(httpSignatureVerifyService, apService)
} }
} }
client.post("/users/test/inbox").let { client.post("/users/test/inbox").let {

View File

@ -12,7 +12,7 @@ import dev.usbharu.hideout.domain.model.ap.Person
import dev.usbharu.hideout.domain.model.hideout.entity.User import dev.usbharu.hideout.domain.model.hideout.entity.User
import dev.usbharu.hideout.plugins.configureSerialization import dev.usbharu.hideout.plugins.configureSerialization
import dev.usbharu.hideout.query.UserQueryService import dev.usbharu.hideout.query.UserQueryService
import dev.usbharu.hideout.service.activitypub.ActivityPubUserService import dev.usbharu.hideout.service.ap.APUserService
import dev.usbharu.hideout.util.HttpUtil.Activity import dev.usbharu.hideout.util.HttpUtil.Activity
import dev.usbharu.hideout.util.HttpUtil.JsonLd import dev.usbharu.hideout.util.HttpUtil.JsonLd
import io.ktor.client.request.* import io.ktor.client.request.*
@ -63,14 +63,14 @@ class UsersAPTest {
) )
person.context = listOf("https://www.w3.org/ns/activitystreams") person.context = listOf("https://www.w3.org/ns/activitystreams")
val activityPubUserService = mock<ActivityPubUserService> { val apUserService = mock<APUserService> {
onBlocking { getPersonByName(anyString()) } doReturn person onBlocking { getPersonByName(anyString()) } doReturn person
} }
application { application {
configureSerialization() configureSerialization()
routing { routing {
usersAP(activityPubUserService, mock(), mock(), TestTransaction) usersAP(apUserService, mock(), mock(), TestTransaction)
} }
} }
client.get("/users/test") { client.get("/users/test") {
@ -121,14 +121,14 @@ class UsersAPTest {
) )
person.context = listOf("https://www.w3.org/ns/activitystreams") person.context = listOf("https://www.w3.org/ns/activitystreams")
val activityPubUserService = mock<ActivityPubUserService> { val apUserService = mock<APUserService> {
onBlocking { getPersonByName(anyString()) } doReturn person onBlocking { getPersonByName(anyString()) } doReturn person
} }
application { application {
configureSerialization() configureSerialization()
routing { routing {
usersAP(activityPubUserService, mock(), mock(), TestTransaction) usersAP(apUserService, mock(), mock(), TestTransaction)
} }
} }
client.get("/users/test") { client.get("/users/test") {

View File

@ -1,7 +1,7 @@
@file:OptIn(ExperimentalCoroutinesApi::class) @file:OptIn(ExperimentalCoroutinesApi::class)
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.config.Config
import dev.usbharu.hideout.config.ConfigData import dev.usbharu.hideout.config.ConfigData
@ -25,7 +25,7 @@ import utils.JsonObjectMapper
import java.time.Instant import java.time.Instant
import kotlin.test.assertEquals import kotlin.test.assertEquals
class ActivityPubNoteServiceImplTest { class APNoteServiceImplTest {
@Test @Test
fun `createPost 新しい投稿`() = runTest { fun `createPost 新しい投稿`() = runTest {
val followers = listOf<User>( val followers = listOf<User>(
@ -76,7 +76,7 @@ class ActivityPubNoteServiceImplTest {
} }
val jobQueueParentService = mock<JobQueueParentService>() val jobQueueParentService = mock<JobQueueParentService>()
val activityPubNoteService = val activityPubNoteService =
ActivityPubNoteServiceImpl( APNoteServiceImpl(
mock(), mock(),
jobQueueParentService, jobQueueParentService,
mock(), mock(),
@ -107,7 +107,7 @@ class ActivityPubNoteServiceImplTest {
respondOk() respondOk()
} }
) )
val activityPubNoteService = ActivityPubNoteServiceImpl( val activityPubNoteService = APNoteServiceImpl(
httpClient, httpClient,
mock(), mock(),
mock(), mock(),

View File

@ -1,7 +1,7 @@
@file:OptIn(ExperimentalCoroutinesApi::class) @file:OptIn(ExperimentalCoroutinesApi::class)
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
package dev.usbharu.hideout.service.activitypub package dev.usbharu.hideout.service.ap
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.config.Config
@ -27,14 +27,14 @@ import utils.JsonObjectMapper
import utils.TestTransaction import utils.TestTransaction
import java.time.Instant import java.time.Instant
class ActivityPubReceiveFollowServiceImplTest { class APReceiveFollowServiceImplTest {
@Test @Test
fun `receiveFollow フォロー受付処理`() = runTest { fun `receiveFollow フォロー受付処理`() = runTest {
val jobQueueParentService = mock<JobQueueParentService> { val jobQueueParentService = mock<JobQueueParentService> {
onBlocking { schedule(eq(ReceiveFollowJob), any()) } doReturn Unit onBlocking { schedule(eq(ReceiveFollowJob), any()) } doReturn Unit
} }
val activityPubFollowService = val activityPubFollowService =
ActivityPubReceiveFollowServiceImpl(jobQueueParentService, mock(), mock(), mock(), mock(), TestTransaction) APReceiveFollowServiceImpl(jobQueueParentService, mock(), mock(), mock(), mock(), TestTransaction)
activityPubFollowService.receiveFollow( activityPubFollowService.receiveFollow(
Follow( Follow(
emptyList(), emptyList(),
@ -96,7 +96,7 @@ class ActivityPubReceiveFollowServiceImplTest {
) )
) )
val activityPubUserService = mock<ActivityPubUserService> { val apUserService = mock<APUserService> {
onBlocking { fetchPerson(anyString(), any()) } doReturn person onBlocking { fetchPerson(anyString(), any()) } doReturn person
} }
val userQueryService = mock<UserQueryService> { val userQueryService = mock<UserQueryService> {
@ -132,9 +132,9 @@ class ActivityPubReceiveFollowServiceImplTest {
onBlocking { followRequest(any(), any()) } doReturn false onBlocking { followRequest(any(), any()) } doReturn false
} }
val activityPubFollowService = val activityPubFollowService =
ActivityPubReceiveFollowServiceImpl( APReceiveFollowServiceImpl(
mock(), mock(),
activityPubUserService, apUserService,
userService, userService,
HttpClient( HttpClient(
MockEngine { httpRequestData -> MockEngine { httpRequestData ->