From 9558a53df157bb9ea88f39cc98c304beb7dd190f Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Mon, 10 Apr 2023 13:41:07 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E3=82=AF=E3=83=A9=E3=82=B9=E3=80=81=E3=82=A4=E3=83=B3=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=83=88=E7=AD=89=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../routing/activitypub/UserRouting.kt | 2 - .../hideout/routing/userActivityPubRouting.kt | 54 ------------------- .../hideout/routing/UserRoutingKtTest.kt | 12 ----- .../routing/activitypub/InboxRoutingKtTest.kt | 4 ++ 4 files changed, 4 insertions(+), 68 deletions(-) delete mode 100644 src/main/kotlin/dev/usbharu/hideout/routing/userActivityPubRouting.kt delete mode 100644 src/test/kotlin/dev/usbharu/hideout/routing/UserRoutingKtTest.kt create mode 100644 src/test/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRoutingKtTest.kt diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/UserRouting.kt b/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/UserRouting.kt index 97280087..36b4d80d 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/UserRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/UserRouting.kt @@ -1,6 +1,5 @@ package dev.usbharu.hideout.routing.activitypub -import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.exception.ParameterNotExistException import dev.usbharu.hideout.plugins.respondAp import dev.usbharu.hideout.service.activitypub.ActivityPubUserService @@ -9,7 +8,6 @@ import dev.usbharu.hideout.util.HttpUtil.JsonLd import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.request.* -import io.ktor.server.response.* import io.ktor.server.routing.* fun Routing.usersAP(activityPubUserService: ActivityPubUserService) { diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/userActivityPubRouting.kt b/src/main/kotlin/dev/usbharu/hideout/routing/userActivityPubRouting.kt deleted file mode 100644 index 73d54fa8..00000000 --- a/src/main/kotlin/dev/usbharu/hideout/routing/userActivityPubRouting.kt +++ /dev/null @@ -1,54 +0,0 @@ -package dev.usbharu.hideout.routing - -import com.fasterxml.jackson.module.kotlin.readValue -import dev.usbharu.hideout.ap.Follow -import dev.usbharu.hideout.config.Config -import dev.usbharu.hideout.service.impl.ActivityPubService -import dev.usbharu.hideout.service.impl.ActivityPubUserService -import dev.usbharu.hideout.util.HttpUtil -import io.ktor.http.* -import io.ktor.server.application.* -import io.ktor.server.request.* -import io.ktor.server.response.* -import io.ktor.server.routing.* - -fun Application.userActivityPubRouting(activityPubService: ActivityPubService, activityPubUserService: ActivityPubUserService) { - routing { - route("/users/{name}") { - route("/inbox") { - get { - call.respond(HttpStatusCode.MethodNotAllowed) - } - post { - if (!HttpUtil.isContentTypeOfActivityPub(call.request.contentType())) { - return@post call.respond(HttpStatusCode.BadRequest) - } - val bodyText = call.receiveText() - println(bodyText) - when (activityPubService.switchApType(bodyText)) { - ActivityPubService.ActivityType.Follow -> { - val readValue = Config.configData.objectMapper.readValue(bodyText) - activityPubUserService.receiveFollow(readValue) - return@post call.respond(HttpStatusCode.Accepted) - } - - ActivityPubService.ActivityType.Undo -> { - return@post call.respond(HttpStatusCode.Accepted) - } - } - - } - } - route("/outbox") { - get { - call.respond(HttpStatusCode.MethodNotAllowed) - - } - post { - - call.respond(HttpStatusCode.MethodNotAllowed) - } - } - } - } -} diff --git a/src/test/kotlin/dev/usbharu/hideout/routing/UserRoutingKtTest.kt b/src/test/kotlin/dev/usbharu/hideout/routing/UserRoutingKtTest.kt deleted file mode 100644 index 6027b7e2..00000000 --- a/src/test/kotlin/dev/usbharu/hideout/routing/UserRoutingKtTest.kt +++ /dev/null @@ -1,12 +0,0 @@ -package dev.usbharu.hideout.routing - -import org.junit.jupiter.api.Test - -class UserRoutingKtTest { - @Test - fun userIconTest() { - println(String.Companion::class.java.classLoader) - println(String::class.java.classLoader) - println(String.javaClass.classLoader.getResourceAsStream("icon.png")?.readAllBytes()) - } -} diff --git a/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRoutingKtTest.kt b/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRoutingKtTest.kt new file mode 100644 index 00000000..3ad053bf --- /dev/null +++ b/src/test/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRoutingKtTest.kt @@ -0,0 +1,4 @@ +package dev.usbharu.hideout.routing.activitypub +class InboxRoutingKtTest { + +}