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
|
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 dev.usbharu.hideout.core.config.ApplicationConfig
|
||||||
import org.springframework.context.annotation.Bean
|
import org.springframework.context.annotation.Bean
|
||||||
import org.springframework.context.annotation.Configuration
|
import org.springframework.context.annotation.Configuration
|
||||||
|
@ -12,7 +12,8 @@ class WebFingerHostMetaLinkConfiguration(private val applicationConfig: Applicat
|
||||||
return Link(
|
return Link(
|
||||||
rel = "lrdd",
|
rel = "lrdd",
|
||||||
type = "application/jrd+json",
|
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
|
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.core.annotation.Order
|
||||||
import org.springframework.http.MediaType
|
import org.springframework.http.MediaType
|
||||||
import org.springframework.http.ResponseEntity
|
import org.springframework.http.ResponseEntity
|
||||||
|
@ -14,19 +12,19 @@ import org.springframework.web.bind.annotation.RestController
|
||||||
class HostmetaController(private val linkList: List<Link> = emptyList()) {
|
class HostmetaController(private val linkList: List<Link> = emptyList()) {
|
||||||
@Order(1)
|
@Order(1)
|
||||||
@GetMapping("/host-meta")
|
@GetMapping("/host-meta")
|
||||||
fun hostmeta(): ResponseEntity<WebHostMetadata> {
|
fun hostmeta(): ResponseEntity<XRD> {
|
||||||
return ResponseEntity.ok().contentType(MediaType("application", "xrd+xml"))
|
return ResponseEntity.ok().contentType(MediaType("application", "xrd+xml"))
|
||||||
.body(WebHostMetadata(linkList))
|
.body(XRD(linkList))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Order(2)
|
@Order(2)
|
||||||
@GetMapping("/host-meta", produces = ["application/json"])
|
@GetMapping("/host-meta", produces = ["application/json"])
|
||||||
fun hostmetaJson(): WebHostMetadata {
|
fun hostmetaJson(): XRD {
|
||||||
return WebHostMetadata(linkList)
|
return XRD(linkList)
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/host-meta.json", produces = ["application/json"])
|
@GetMapping("/host-meta.json", produces = ["application/json"])
|
||||||
fun hostmetaJson2(): WebHostMetadata {
|
fun hostmetaJson2(): XRD {
|
||||||
return WebHostMetadata(linkList)
|
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.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper
|
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper
|
||||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty
|
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty
|
||||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement
|
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")
|
@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")
|
@JacksonXmlProperty(localName = "Link", namespace = "http://docs.oasis-open.org/ns/xri/xrd-1.0")
|
||||||
@JacksonXmlElementWrapper(useWrapping = false)
|
@JacksonXmlElementWrapper(useWrapping = false)
|
||||||
@JsonProperty("links")
|
@JsonProperty("links")
|
||||||
val links: List<Link>,
|
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(
|
class Link(
|
||||||
@JacksonXmlProperty(localName = "rel", isAttribute = true) val rel: String,
|
@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,
|
@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