mirror of https://github.com/usbharu/Hideout.git
fix: activitypubのレスポンスを修正
This commit is contained in:
parent
f119493b19
commit
081be4e305
|
@ -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,19 +32,24 @@ 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<IUserAuthRepository>{UserAuthRepository(get())}
|
}
|
||||||
single<IUserAuthService>{ UserAuthService(get(),get()) }
|
single<IUserRepository> { UserRepository(get()) }
|
||||||
|
single<IUserAuthRepository> { UserAuthRepository(get()) }
|
||||||
|
single<IUserAuthService> { UserAuthService(get(), get()) }
|
||||||
single<UserService> { UserService(get()) }
|
single<UserService> { UserService(get()) }
|
||||||
single<ActivityPubUserService> { ActivityPubUserService(get())}
|
single<ActivityPubUserService> { ActivityPubUserService(get()) }
|
||||||
}
|
}
|
||||||
configureKoin(module)
|
configureKoin(module)
|
||||||
val configData by inject<ConfigData>()
|
val configData by inject<ConfigData>()
|
||||||
|
@ -59,7 +66,7 @@ fun Application.module() {
|
||||||
configureSerialization()
|
configureSerialization()
|
||||||
configureSockets()
|
configureSockets()
|
||||||
val activityPubUserService by inject<ActivityPubUserService>()
|
val activityPubUserService by inject<ActivityPubUserService>()
|
||||||
user(userService,activityPubUserService)
|
user(userService, activityPubUserService)
|
||||||
login()
|
login()
|
||||||
register(userAuthService)
|
register(userAuthService)
|
||||||
wellKnown(userService)
|
wellKnown(userService)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue