From de0516d7102230ccb06078a2a30de4b2ef478f0e Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 24 Mar 2023 17:46:01 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20misskey=E3=81=8C=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=8F=E3=82=8B=E3=82=A2=E3=82=AB=E3=82=A6?= =?UTF-8?q?=E3=83=B3=E3=83=88=E5=90=8D=E3=81=AE=E5=BD=A2=E5=BC=8F=E3=81=AB?= =?UTF-8?q?=E3=82=82=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hideout/routing/WellKnownRouting.kt | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/WellKnownRouting.kt b/src/main/kotlin/dev/usbharu/hideout/routing/WellKnownRouting.kt index 5a662a11..aa8a10eb 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/WellKnownRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/WellKnownRouting.kt @@ -1,7 +1,6 @@ package dev.usbharu.hideout.routing import dev.usbharu.hideout.config.Config -import dev.usbharu.hideout.exception.UserNotFoundException import dev.usbharu.hideout.service.UserService import dev.usbharu.hideout.util.HttpUtil.Activity import io.ktor.http.* @@ -46,26 +45,33 @@ fun Application.wellKnown(userService: UserService) { } get("/webfinger") { - val uri = call.request.queryParameters["resource"] ?: return@get call.respondText("resource was not found", + val uri = call.request.queryParameters["resource"] ?: return@get call.respondText( + "resource was not found", status = HttpStatusCode.BadRequest ) val decodeURLPart = uri.decodeURLPart() if (!decodeURLPart.startsWith("acct:")) { - return@get call.respondText("$uri was not found.",status =HttpStatusCode.BadRequest) + return@get call.respondText( + "$uri was not found.", + status = HttpStatusCode.BadRequest + ) } - val accountName = uri.substringBeforeLast("@").substringAfter("@") + val accountName = + uri.substringBeforeLast("@").substringAfter("acct:").trimStart('@') val userEntity = userService.findByName(accountName) - return@get call.respond(WebFingerResource( - subject = decodeURLPart, - listOf( - WebFingerResource.Link( - rel ="self", - type = ContentType.Application.Activity.toString(), - href = "${Config.configData.hostname}/users/${userEntity.name}" + return@get call.respond( + WebFingerResource( + subject = decodeURLPart, + listOf( + WebFingerResource.Link( + rel = "self", + type = ContentType.Application.Activity.toString(), + href = "${Config.configData.hostname}/users/${userEntity.name}" + ) ) ) - )) + ) } } @@ -73,7 +79,7 @@ fun Application.wellKnown(userService: UserService) { } @Serializable -data class WebFingerResource(val subject:String,val links:List){ +data class WebFingerResource(val subject: String, val links: List) { @Serializable - data class Link(val rel:String,val type:String,val href:String) + data class Link(val rel: String, val type: String, val href: String) }