diff --git a/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/JsonLd.kt b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/JsonLd.kt index 9700c9d0..f6c4c73a 100644 --- a/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/JsonLd.kt +++ b/src/main/kotlin/dev/usbharu/hideout/domain/model/ap/JsonLd.kt @@ -2,6 +2,7 @@ package dev.usbharu.hideout.domain.model.ap import com.fasterxml.jackson.annotation.JsonAutoDetect import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.databind.JsonDeserializer @@ -15,7 +16,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize open class JsonLd { @JsonProperty("@context") @JsonDeserialize(contentUsing = ContextDeserializer::class) - @JsonSerialize(using = ContextSerializer::class) + @JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY, using = ContextSerializer::class) + @JsonInclude(JsonInclude.Include.NON_EMPTY) var context: List = emptyList() @JsonCreator @@ -57,6 +59,12 @@ class ContextDeserializer : JsonDeserializer() { } class ContextSerializer : JsonSerializer>() { + + + override fun isEmpty(value: List?): Boolean { + return value.isNullOrEmpty() + } + override fun serialize(value: List?, gen: JsonGenerator?, serializers: SerializerProvider?) { if (value.isNullOrEmpty()) { gen?.writeNull() diff --git a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubUserServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubUserServiceImpl.kt index 4aca8b88..d63c048f 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubUserServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubUserServiceImpl.kt @@ -89,7 +89,7 @@ class ActivityPubUserServiceImpl( RemoteUserCreateDto( name = person.preferredUsername ?: throw IllegalActivityPubObjectException("preferredUsername is null"), - domain = url.substringAfter(":").substringBeforeLast("/"), + domain = url.substringAfter("://").substringBefore("/"), screenName = (person.name ?: person.preferredUsername) ?: throw IllegalActivityPubObjectException("preferredUsername is null"), description = person.summary ?: "", inbox = person.inbox ?: throw IllegalActivityPubObjectException("inbox is null"),