mirror of
https://github.com/usbharu/Hideout.git
synced 2026-09-12 04:05:40 +00:00
feat: misskeyが要求してくるアカウント名の形式にも対応
This commit is contained in:
@@ -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,17 +45,23 @@ 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(
|
||||
return@get call.respond(
|
||||
WebFingerResource(
|
||||
subject = decodeURLPart,
|
||||
listOf(
|
||||
WebFingerResource.Link(
|
||||
@@ -65,7 +70,8 @@ fun Application.wellKnown(userService: UserService) {
|
||||
href = "${Config.configData.hostname}/users/${userEntity.name}"
|
||||
)
|
||||
)
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user