mirror of https://github.com/usbharu/Hideout.git
refactor: WebHostMetadataをXRDに変更
This commit is contained in:
parent
26b9d640b5
commit
ecdbf74e57
|
@ -1,6 +1,6 @@
|
|||
package dev.usbharu.hideout.activitypub.config
|
||||
|
||||
import dev.usbharu.hideout.activitypub.application.hostmeta.Link
|
||||
import dev.usbharu.hideout.activitypub.interfaces.wellknown.Link
|
||||
import dev.usbharu.hideout.core.config.ApplicationConfig
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
|
@ -12,7 +12,8 @@ class WebFingerHostMetaLinkConfiguration(private val applicationConfig: Applicat
|
|||
return Link(
|
||||
rel = "lrdd",
|
||||
type = "application/jrd+json",
|
||||
template = applicationConfig.url.resolve(".well-known/webfinger").toString() + "?resource={uri}"
|
||||
template = applicationConfig.url.resolve(".well-known/webfinger").toString() + "?resource={uri}",
|
||||
href = null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package dev.usbharu.hideout.activitypub.interfaces.wellknown
|
||||
|
||||
import dev.usbharu.hideout.activitypub.application.hostmeta.Link
|
||||
import dev.usbharu.hideout.activitypub.application.hostmeta.WebHostMetadata
|
||||
import org.springframework.core.annotation.Order
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.http.ResponseEntity
|
||||
|
@ -14,19 +12,19 @@ import org.springframework.web.bind.annotation.RestController
|
|||
class HostmetaController(private val linkList: List<Link> = emptyList()) {
|
||||
@Order(1)
|
||||
@GetMapping("/host-meta")
|
||||
fun hostmeta(): ResponseEntity<WebHostMetadata> {
|
||||
fun hostmeta(): ResponseEntity<XRD> {
|
||||
return ResponseEntity.ok().contentType(MediaType("application", "xrd+xml"))
|
||||
.body(WebHostMetadata(linkList))
|
||||
.body(XRD(linkList))
|
||||
}
|
||||
|
||||
@Order(2)
|
||||
@GetMapping("/host-meta", produces = ["application/json"])
|
||||
fun hostmetaJson(): WebHostMetadata {
|
||||
return WebHostMetadata(linkList)
|
||||
fun hostmetaJson(): XRD {
|
||||
return XRD(linkList)
|
||||
}
|
||||
|
||||
@GetMapping("/host-meta.json", produces = ["application/json"])
|
||||
fun hostmetaJson2(): WebHostMetadata {
|
||||
return WebHostMetadata(linkList)
|
||||
fun hostmetaJson2(): XRD {
|
||||
return XRD(linkList)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,31 @@
|
|||
package dev.usbharu.hideout.activitypub.application.hostmeta
|
||||
package dev.usbharu.hideout.activitypub.interfaces.wellknown
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement
|
||||
import java.net.URI
|
||||
|
||||
@JacksonXmlRootElement(localName = "XRD", namespace = "http://docs.oasis-open.org/ns/xri/xrd-1.0")
|
||||
class WebHostMetadata(
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
class XRD(
|
||||
@JacksonXmlProperty(localName = "Link", namespace = "http://docs.oasis-open.org/ns/xri/xrd-1.0")
|
||||
@JacksonXmlElementWrapper(useWrapping = false)
|
||||
@JsonProperty("links")
|
||||
val links: List<Link>,
|
||||
@JacksonXmlProperty(localName = "subject")
|
||||
@JsonProperty(value = "subject")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
val subject: URI? = null,
|
||||
)
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
class Link(
|
||||
@JacksonXmlProperty(localName = "rel", isAttribute = true) val rel: String,
|
||||
@JacksonXmlProperty(localName = "template", isAttribute = true) val template: String,
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JacksonXmlProperty(localName = "template", isAttribute = true) val template: String?,
|
||||
@JacksonXmlProperty(localName = "type", isAttribute = true) val type: String,
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JacksonXmlProperty(localName = "href", isAttribute = true) val href: String?,
|
||||
)
|
Loading…
Reference in New Issue