From 7eaa5cb51da0cd1fd33df1f404b64daa87feb3a2 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 21 Apr 2023 19:47:15 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AB=E4=BB=AE=E3=81=AE=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/dev/usbharu/hideout/plugins/Routing.kt | 4 ++-- .../dev/usbharu/hideout/routing/activitypub/UserRouting.kt | 7 ++++++- .../kotlin/dev/usbharu/hideout/routing/api/v1/Statuses.kt | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/Routing.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/Routing.kt index 474cff2a..fc4f0742 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/Routing.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/Routing.kt @@ -25,10 +25,10 @@ fun Application.configureRouting( routing { inbox(httpSignatureVerifyService, activityPubService) outbox() - usersAP(activityPubUserService) + usersAP(activityPubUserService,userService) webfinger(userService) - route("api/v1") { + route("/api/v1") { statuses(postService) } 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 36b4d80d..9d4a99e1 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/UserRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/UserRouting.kt @@ -3,14 +3,16 @@ package dev.usbharu.hideout.routing.activitypub import dev.usbharu.hideout.exception.ParameterNotExistException import dev.usbharu.hideout.plugins.respondAp import dev.usbharu.hideout.service.activitypub.ActivityPubUserService +import dev.usbharu.hideout.service.impl.UserService import dev.usbharu.hideout.util.HttpUtil.Activity 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) { +fun Routing.usersAP(activityPubUserService: ActivityPubUserService,userService:UserService) { route("/users/{name}") { createChild(ContentTypeRouteSelector(ContentType.Application.Activity, ContentType.Application.JsonLd)).handle { val name = @@ -21,6 +23,9 @@ fun Routing.usersAP(activityPubUserService: ActivityPubUserService) { HttpStatusCode.OK ) } + get { + call.respondText(userService.findByName(call.parameters["name"]!!).toString()) + } } } diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/api/v1/Statuses.kt b/src/main/kotlin/dev/usbharu/hideout/routing/api/v1/Statuses.kt index e5194667..710354a0 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/api/v1/Statuses.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/api/v1/Statuses.kt @@ -10,7 +10,7 @@ import io.ktor.server.response.* import io.ktor.server.routing.* fun Route.statuses(postService: IPostService) { - route("statuses") { + route("/statuses") { post { val status: StatusForPost = call.receive() val post = Post(