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) } }