fix: activitypubのレスポンスを修正

This commit is contained in:
usbharu 2023-03-24 18:27:59 +09:00
parent f119493b19
commit 081be4e305
4 changed files with 24 additions and 17 deletions

View File

@ -1,5 +1,7 @@
package dev.usbharu.hideout package dev.usbharu.hideout
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import dev.usbharu.hideout.config.Config import dev.usbharu.hideout.config.Config
import dev.usbharu.hideout.config.ConfigData import dev.usbharu.hideout.config.ConfigData
@ -21,7 +23,7 @@ import io.ktor.server.auth.*
import io.ktor.util.* import io.ktor.util.*
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.util.Base64 import java.util.*
fun main(args: Array<String>): Unit = fun main(args: Array<String>): Unit =
io.ktor.server.netty.EngineMain.main(args) io.ktor.server.netty.EngineMain.main(args)
@ -30,14 +32,19 @@ fun main(args: Array<String>): Unit =
fun Application.module() { fun Application.module() {
val module = org.koin.dsl.module { val module = org.koin.dsl.module {
single<Database>{ Database.connect( single<Database> {
Database.connect(
url = "jdbc:h2:./test;MODE=POSTGRESQL", url = "jdbc:h2:./test;MODE=POSTGRESQL",
driver = "org.h2.Driver", driver = "org.h2.Driver",
) } )
single<ConfigData>{ ConfigData( }
single<ConfigData> {
ConfigData(
environment.config.property("hideout.hostname").getString(), environment.config.property("hideout.hostname").getString(),
jacksonObjectMapper() jacksonObjectMapper().enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
) } .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
)
}
single<IUserRepository> { UserRepository(get()) } single<IUserRepository> { UserRepository(get()) }
single<IUserAuthRepository> { UserAuthRepository(get()) } single<IUserAuthRepository> { UserAuthRepository(get()) }
single<IUserAuthService> { UserAuthService(get(), get()) } single<IUserAuthService> { UserAuthService(get(), get()) }

View File

@ -6,7 +6,7 @@ open class Image : Object {
protected constructor() : super() protected constructor() : super()
constructor(type: List<String> = emptyList(), name: String, mediaType: String?, url: String?) : super( constructor(type: List<String> = emptyList(), name: String, mediaType: String?, url: String?) : super(
type, add(type,"Image"),
name name
) { ) {
this.mediaType = mediaType this.mediaType = mediaType

View File

@ -8,7 +8,7 @@ import io.ktor.server.application.*
import io.ktor.server.response.* import io.ktor.server.response.*
suspend fun <T : JsonLd> ApplicationCall.respondAp(message: T, status: HttpStatusCode = HttpStatusCode.OK) { suspend fun <T : JsonLd> ApplicationCall.respondAp(message: T, status: HttpStatusCode = HttpStatusCode.OK) {
message.context += "https://www.w3.org/activitystreams" message.context += "https://www.w3.org/ns/activitystreams"
val activityJson = Config.configData.objectMapper.writeValueAsString(message) val activityJson = Config.configData.objectMapper.writeValueAsString(message)
respondText(activityJson, ContentType.Application.Activity, status) respondText(activityJson, ContentType.Application.Activity, status)
} }

View File

@ -10,7 +10,7 @@ class ActivityPubUserService(private val userService: UserService) {
val userUrl = "${Config.configData.hostname}/users/$name" val userUrl = "${Config.configData.hostname}/users/$name"
return Person( return Person(
emptyList(), emptyList(),
"Icon", userEntity.name,
userUrl, userUrl,
name, name,
userEntity.description, userEntity.description,