fix: runBlockingで包むように

This commit is contained in:
usbharu 2023-09-24 11:37:15 +09:00
parent 0171012912
commit 721cdc9d49
1 changed files with 5 additions and 6 deletions

View File

@ -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<WebFinger> {
val acct = AcctUtil.parse(resource)
@GetMapping("/.well-known/webfinger")
fun webfinger(@RequestParam("resource") resource: String): ResponseEntity<WebFinger> = 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)
}
}