fix: acceptにコンテンツタイプを指定

This commit is contained in:
usbharu 2023-03-30 21:18:15 +09:00
parent 11afa84af6
commit ad17456754
2 changed files with 4 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import io.ktor.serialization.jackson.*
import io.ktor.server.application.* import io.ktor.server.application.*
import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.Database
import org.koin.ktor.ext.inject import org.koin.ktor.ext.inject
import java.lang.Compiler.enable
import java.util.* import java.util.*
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args) fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
@ -49,7 +50,7 @@ fun Application.module() {
HttpClient(CIO) { HttpClient(CIO) {
install(ContentNegotiation) { install(ContentNegotiation) {
jackson(ContentType.Application.Activity) { jackson {
enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY) enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
setSerializationInclusion(JsonInclude.Include.NON_EMPTY) setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)

View File

@ -2,6 +2,7 @@ package dev.usbharu.hideout.service
import dev.usbharu.hideout.ap.* import dev.usbharu.hideout.ap.*
import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.config.Config
import dev.usbharu.hideout.util.HttpUtil.Activity
import io.ktor.client.* import io.ktor.client.*
import io.ktor.client.call.* import io.ktor.client.call.*
import io.ktor.client.plugins.* import io.ktor.client.plugins.*
@ -48,6 +49,7 @@ class ActivityPubUserService(
val person = webFingerService.fetchUserModel(actor) ?: throw IllegalArgumentException("actor is not found") val person = webFingerService.fetchUserModel(actor) ?: throw IllegalArgumentException("actor is not found")
val inboxUrl = person.inbox ?: throw IllegalArgumentException("inbox is not found") val inboxUrl = person.inbox ?: throw IllegalArgumentException("inbox is not found")
httpClient.post(inboxUrl) { httpClient.post(inboxUrl) {
contentType(ContentType.Application.Activity)
setBody(Accept( setBody(Accept(
name = "Follow", name = "Follow",
`object` = follow, `object` = follow,