From 721cdc9d49acbe6740293cbf2f4680ed7f9d3831 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:37:15 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20runBlocking=E3=81=A7=E5=8C=85=E3=82=80?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/wellknown/WebFingerController.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/controller/wellknown/WebFingerController.kt b/src/main/kotlin/dev/usbharu/hideout/controller/wellknown/WebFingerController.kt index 2542f5d8..3ea7fffd 100644 --- a/src/main/kotlin/dev/usbharu/hideout/controller/wellknown/WebFingerController.kt +++ b/src/main/kotlin/dev/usbharu/hideout/controller/wellknown/WebFingerController.kt @@ -4,23 +4,22 @@ import dev.usbharu.hideout.config.ApplicationConfig import dev.usbharu.hideout.domain.model.wellknown.WebFinger import dev.usbharu.hideout.service.api.WebFingerApiService import dev.usbharu.hideout.util.AcctUtil +import kotlinx.coroutines.runBlocking import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.stereotype.Controller import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam import java.net.URL @Controller -@RequestMapping("/.well-known") class WebFingerController( private val webFingerApiService: WebFingerApiService, private val applicationConfig: ApplicationConfig ) { - @GetMapping("/webfinger") - suspend fun webfinger(@RequestParam resource: String): ResponseEntity { - val acct = AcctUtil.parse(resource) + @GetMapping("/.well-known/webfinger") + fun webfinger(@RequestParam("resource") resource: String): ResponseEntity = runBlocking { + val acct = AcctUtil.parse(resource.replace("acct:", "")) val user = webFingerApiService.findByNameAndDomain(acct.username, acct.domain ?: URL(applicationConfig.url).host) val webFinger = WebFinger( @@ -33,6 +32,6 @@ class WebFingerController( ) ) ) - return ResponseEntity(webFinger, HttpStatus.OK) + ResponseEntity(webFinger, HttpStatus.OK) } }