From e69618cd812a4c6c6b88d52f1059515667110729 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 14 Apr 2023 15:38:49 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20AP=E9=96=A2=E4=BF=82=E3=81=AE?= =?UTF-8?q?=E3=83=A2=E3=83=87=E3=83=AB=E3=82=92=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hideout/domain/model/ActivityPubStringResponse.kt | 2 +- .../dev/usbharu/hideout/{ => domain/model}/ap/Accept.kt | 4 ++-- .../dev/usbharu/hideout/{ => domain/model}/ap/Follow.kt | 4 ++-- .../dev/usbharu/hideout/{ => domain/model}/ap/Image.kt | 2 +- .../dev/usbharu/hideout/{ => domain/model}/ap/JsonLd.kt | 3 +-- .../kotlin/dev/usbharu/hideout/{ => domain/model}/ap/Key.kt | 4 ++-- .../dev/usbharu/hideout/{ => domain/model}/ap/Object.kt | 2 +- .../dev/usbharu/hideout/{ => domain/model}/ap/Person.kt | 6 +++--- src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt | 2 +- .../hideout/service/activitypub/ActivityPubFollowService.kt | 4 ++-- .../service/activitypub/ActivityPubFollowServiceImpl.kt | 4 ++-- .../hideout/service/activitypub/ActivityPubServiceImpl.kt | 5 +---- .../hideout/service/activitypub/ActivityPubUserService.kt | 6 +++--- .../service/activitypub/ActivityPubUserServiceImpl.kt | 6 +++--- .../dev/usbharu/hideout/ap/ContextDeserializerTest.kt | 2 +- .../kotlin/dev/usbharu/hideout/ap/ContextSerializerTest.kt | 3 ++- .../kotlin/dev/usbharu/hideout/plugins/ActivityPubKtTest.kt | 2 +- .../dev/usbharu/hideout/routing/activitypub/UsersAPTest.kt | 6 +++--- .../service/activitypub/ActivityPubFollowServiceImplTest.kt | 2 +- 19 files changed, 33 insertions(+), 36 deletions(-) rename src/main/kotlin/dev/usbharu/hideout/{ => domain/model}/ap/Accept.kt (91%) rename src/main/kotlin/dev/usbharu/hideout/{ => domain/model}/ap/Follow.kt (83%) rename src/main/kotlin/dev/usbharu/hideout/{ => domain/model}/ap/Image.kt (95%) rename src/main/kotlin/dev/usbharu/hideout/{ => domain/model}/ap/JsonLd.kt (96%) rename src/main/kotlin/dev/usbharu/hideout/{ => domain/model}/ap/Key.kt (93%) rename src/main/kotlin/dev/usbharu/hideout/{ => domain/model}/ap/Object.kt (97%) rename src/main/kotlin/dev/usbharu/hideout/{ => domain/model}/ap/Person.kt (94%) diff --git a/src/main/kotlin/dev/usbharu/hideout/domain/model/ActivityPubStringResponse.kt b/src/main/kotlin/dev/usbharu/hideout/domain/model/ActivityPubStringResponse.kt index 2e4b8b4d..402079b0 100644 --- a/src/main/kotlin/dev/usbharu/hideout/domain/model/ActivityPubStringResponse.kt +++ b/src/main/kotlin/dev/usbharu/hideout/domain/model/ActivityPubStringResponse.kt @@ -1,6 +1,6 @@ package dev.usbharu.hideout.domain.model -import dev.usbharu.hideout.ap.JsonLd +import dev.usbharu.hideout.domain.model.ap.JsonLd import dev.usbharu.hideout.util.HttpUtil.Activity import io.ktor.http.* diff --git a/src/main/kotlin/dev/usbharu/hideout/ap/Accept.kt b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Accept.kt similarity index 91% rename from src/main/kotlin/dev/usbharu/hideout/ap/Accept.kt rename to src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Accept.kt index 35b822c8..58889069 100644 --- a/src/main/kotlin/dev/usbharu/hideout/ap/Accept.kt +++ b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Accept.kt @@ -1,7 +1,7 @@ -package dev.usbharu.hideout.ap +package dev.usbharu.hideout.domain.model.ap open class Accept : Object { - public var `object`:Object? = null + public var `object`: Object? = null public var actor:String? = null protected constructor() : super() constructor( diff --git a/src/main/kotlin/dev/usbharu/hideout/ap/Follow.kt b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Follow.kt similarity index 83% rename from src/main/kotlin/dev/usbharu/hideout/ap/Follow.kt rename to src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Follow.kt index b2ab16c6..c73c85a3 100644 --- a/src/main/kotlin/dev/usbharu/hideout/ap/Follow.kt +++ b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Follow.kt @@ -1,6 +1,6 @@ -package dev.usbharu.hideout.ap +package dev.usbharu.hideout.domain.model.ap -open class Follow : Object{ +open class Follow : Object { public var `object`:String? = null public var actor:String? = null protected constructor() : super() diff --git a/src/main/kotlin/dev/usbharu/hideout/ap/Image.kt b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Image.kt similarity index 95% rename from src/main/kotlin/dev/usbharu/hideout/ap/Image.kt rename to src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Image.kt index 29639e20..5767e7b7 100644 --- a/src/main/kotlin/dev/usbharu/hideout/ap/Image.kt +++ b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Image.kt @@ -1,4 +1,4 @@ -package dev.usbharu.hideout.ap +package dev.usbharu.hideout.domain.model.ap open class Image : Object { private var mediaType: String? = null diff --git a/src/main/kotlin/dev/usbharu/hideout/ap/JsonLd.kt b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/JsonLd.kt similarity index 96% rename from src/main/kotlin/dev/usbharu/hideout/ap/JsonLd.kt rename to src/main/kotlin/dev/usbharu/hideout/domain/model/ap/JsonLd.kt index 285319bd..4965814a 100644 --- a/src/main/kotlin/dev/usbharu/hideout/ap/JsonLd.kt +++ b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/JsonLd.kt @@ -1,10 +1,9 @@ -package dev.usbharu.hideout.ap +package dev.usbharu.hideout.domain.model.ap import com.fasterxml.jackson.annotation.JsonAutoDetect import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.TreeNode import com.fasterxml.jackson.databind.JsonDeserializer import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.JsonSerializer diff --git a/src/main/kotlin/dev/usbharu/hideout/ap/Key.kt b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Key.kt similarity index 93% rename from src/main/kotlin/dev/usbharu/hideout/ap/Key.kt rename to src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Key.kt index b3dccdfd..ec79ace0 100644 --- a/src/main/kotlin/dev/usbharu/hideout/ap/Key.kt +++ b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Key.kt @@ -1,6 +1,6 @@ -package dev.usbharu.hideout.ap +package dev.usbharu.hideout.domain.model.ap -open class Key : Object{ +open class Key : Object { var id:String? = null var owner:String? = null var publicKeyPem:String? = null diff --git a/src/main/kotlin/dev/usbharu/hideout/ap/Object.kt b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Object.kt similarity index 97% rename from src/main/kotlin/dev/usbharu/hideout/ap/Object.kt rename to src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Object.kt index 27362b30..faca1cd4 100644 --- a/src/main/kotlin/dev/usbharu/hideout/ap/Object.kt +++ b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Object.kt @@ -1,4 +1,4 @@ -package dev.usbharu.hideout.ap +package dev.usbharu.hideout.domain.model.ap import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.databind.JsonSerializer diff --git a/src/main/kotlin/dev/usbharu/hideout/ap/Person.kt b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Person.kt similarity index 94% rename from src/main/kotlin/dev/usbharu/hideout/ap/Person.kt rename to src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Person.kt index 148892b0..cc04bceb 100644 --- a/src/main/kotlin/dev/usbharu/hideout/ap/Person.kt +++ b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/Person.kt @@ -1,4 +1,4 @@ -package dev.usbharu.hideout.ap +package dev.usbharu.hideout.domain.model.ap open class Person : Object { private var id:String? = null @@ -7,8 +7,8 @@ open class Person : Object { var inbox:String? = null var outbox:String? = null private var url:String? = null - private var icon:Image? = null - var publicKey:Key? = null + private var icon: Image? = null + var publicKey: Key? = null protected constructor() : super() constructor( type: List = emptyList(), diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt index 2c8d1d52..db0e6a1f 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt @@ -1,6 +1,6 @@ package dev.usbharu.hideout.plugins -import dev.usbharu.hideout.ap.JsonLd +import dev.usbharu.hideout.domain.model.ap.JsonLd import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.service.IUserAuthService import dev.usbharu.hideout.service.impl.UserAuthService diff --git a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowService.kt b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowService.kt index 4fed9bb6..ed2d0ec9 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowService.kt @@ -1,11 +1,11 @@ package dev.usbharu.hideout.service.activitypub -import dev.usbharu.hideout.ap.Follow +import dev.usbharu.hideout.domain.model.ap.Follow import dev.usbharu.hideout.domain.model.ActivityPubResponse import dev.usbharu.hideout.domain.model.job.ReceiveFollowJob import kjob.core.job.JobProps interface ActivityPubFollowService { - suspend fun receiveFollow(follow:Follow):ActivityPubResponse + suspend fun receiveFollow(follow: Follow):ActivityPubResponse suspend fun receiveFollowJob(props: JobProps) } diff --git a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImpl.kt index 0a606f4a..b734aba1 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImpl.kt @@ -1,8 +1,8 @@ package dev.usbharu.hideout.service.activitypub import com.fasterxml.jackson.module.kotlin.readValue -import dev.usbharu.hideout.ap.Accept -import dev.usbharu.hideout.ap.Follow +import dev.usbharu.hideout.domain.model.ap.Accept +import dev.usbharu.hideout.domain.model.ap.Follow import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.domain.model.ActivityPubResponse import dev.usbharu.hideout.domain.model.ActivityPubStringResponse diff --git a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubServiceImpl.kt index 06224a67..c6424167 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubServiceImpl.kt @@ -1,18 +1,15 @@ package dev.usbharu.hideout.service.activitypub import com.fasterxml.jackson.databind.JsonNode -import dev.usbharu.hideout.ap.Follow +import dev.usbharu.hideout.domain.model.ap.Follow import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.domain.model.ActivityPubResponse import dev.usbharu.hideout.domain.model.job.HideoutJob import dev.usbharu.hideout.domain.model.job.ReceiveFollowJob import dev.usbharu.hideout.exception.JsonParseException -import kjob.core.Job import kjob.core.dsl.JobContextWithProps import kjob.core.job.JobProps import org.slf4j.LoggerFactory -import kotlin.reflect.full.createInstance -import kotlin.reflect.full.primaryConstructor class ActivityPubServiceImpl(private val activityPubFollowService: ActivityPubFollowService) : ActivityPubService { diff --git a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubUserService.kt b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubUserService.kt index 0b67e383..a698670b 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubUserService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubUserService.kt @@ -1,9 +1,9 @@ package dev.usbharu.hideout.service.activitypub -import dev.usbharu.hideout.ap.Person +import dev.usbharu.hideout.domain.model.ap.Person interface ActivityPubUserService { - suspend fun getPersonByName(name:String):Person + suspend fun getPersonByName(name:String): Person - suspend fun fetchPerson(url:String):Person + suspend fun fetchPerson(url:String): Person } diff --git a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubUserServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubUserServiceImpl.kt index 2c5c5002..09c4b601 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubUserServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubUserServiceImpl.kt @@ -1,9 +1,9 @@ package dev.usbharu.hideout.service.activitypub import com.fasterxml.jackson.module.kotlin.readValue -import dev.usbharu.hideout.ap.Image -import dev.usbharu.hideout.ap.Key -import dev.usbharu.hideout.ap.Person +import dev.usbharu.hideout.domain.model.ap.Image +import dev.usbharu.hideout.domain.model.ap.Key +import dev.usbharu.hideout.domain.model.ap.Person import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.domain.model.User import dev.usbharu.hideout.domain.model.UserAuthentication diff --git a/src/test/kotlin/dev/usbharu/hideout/ap/ContextDeserializerTest.kt b/src/test/kotlin/dev/usbharu/hideout/ap/ContextDeserializerTest.kt index a9b933c5..116c028e 100644 --- a/src/test/kotlin/dev/usbharu/hideout/ap/ContextDeserializerTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/ap/ContextDeserializerTest.kt @@ -3,7 +3,7 @@ package dev.usbharu.hideout.ap import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.fasterxml.jackson.module.kotlin.readValue -import org.junit.jupiter.api.Assertions.* +import dev.usbharu.hideout.domain.model.ap.Follow class ContextDeserializerTest { diff --git a/src/test/kotlin/dev/usbharu/hideout/ap/ContextSerializerTest.kt b/src/test/kotlin/dev/usbharu/hideout/ap/ContextSerializerTest.kt index 5558cb68..b93e7872 100644 --- a/src/test/kotlin/dev/usbharu/hideout/ap/ContextSerializerTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/ap/ContextSerializerTest.kt @@ -1,7 +1,8 @@ package dev.usbharu.hideout.ap import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import org.junit.jupiter.api.Assertions.* +import dev.usbharu.hideout.domain.model.ap.Accept +import dev.usbharu.hideout.domain.model.ap.Follow import org.junit.jupiter.api.Test class ContextSerializerTest{ diff --git a/src/test/kotlin/dev/usbharu/hideout/plugins/ActivityPubKtTest.kt b/src/test/kotlin/dev/usbharu/hideout/plugins/ActivityPubKtTest.kt index 19246b90..b5690c99 100644 --- a/src/test/kotlin/dev/usbharu/hideout/plugins/ActivityPubKtTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/plugins/ActivityPubKtTest.kt @@ -1,6 +1,6 @@ package dev.usbharu.hideout.plugins -import dev.usbharu.hideout.ap.JsonLd +import dev.usbharu.hideout.domain.model.ap.JsonLd import dev.usbharu.hideout.domain.model.User import dev.usbharu.hideout.domain.model.UserAuthentication import dev.usbharu.hideout.domain.model.UserAuthenticationEntity diff --git a/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/UsersAPTest.kt b/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/UsersAPTest.kt index e09f504b..6d177521 100644 --- a/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/UsersAPTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/UsersAPTest.kt @@ -6,9 +6,9 @@ import com.fasterxml.jackson.annotation.Nulls import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.fasterxml.jackson.module.kotlin.readValue -import dev.usbharu.hideout.ap.Image -import dev.usbharu.hideout.ap.Key -import dev.usbharu.hideout.ap.Person +import dev.usbharu.hideout.domain.model.ap.Image +import dev.usbharu.hideout.domain.model.ap.Key +import dev.usbharu.hideout.domain.model.ap.Person import dev.usbharu.hideout.plugins.configureRouting import dev.usbharu.hideout.plugins.configureSerialization import dev.usbharu.hideout.service.activitypub.ActivityPubService diff --git a/src/test/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImplTest.kt b/src/test/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImplTest.kt index d447ce3e..c5a0bb5f 100644 --- a/src/test/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImplTest.kt +++ b/src/test/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubFollowServiceImplTest.kt @@ -4,10 +4,10 @@ package dev.usbharu.hideout.service.activitypub import com.fasterxml.jackson.module.kotlin.readValue -import dev.usbharu.hideout.ap.* import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.config.ConfigData import dev.usbharu.hideout.domain.model.UserEntity +import dev.usbharu.hideout.domain.model.ap.* import dev.usbharu.hideout.domain.model.job.ReceiveFollowJob import dev.usbharu.hideout.service.impl.UserService import dev.usbharu.hideout.service.job.JobQueueParentService