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
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||
import dev.usbharu.hideout.config.Config
|
||||
import dev.usbharu.hideout.config.ConfigData
|
||||
|
@ -21,7 +23,7 @@ import io.ktor.server.auth.*
|
|||
import io.ktor.util.*
|
||||
import org.jetbrains.exposed.sql.Database
|
||||
import org.koin.ktor.ext.inject
|
||||
import java.util.Base64
|
||||
import java.util.*
|
||||
|
||||
fun main(args: Array<String>): Unit =
|
||||
io.ktor.server.netty.EngineMain.main(args)
|
||||
|
@ -30,19 +32,24 @@ fun main(args: Array<String>): Unit =
|
|||
fun Application.module() {
|
||||
val module = org.koin.dsl.module {
|
||||
|
||||
single<Database>{ Database.connect(
|
||||
single<Database> {
|
||||
Database.connect(
|
||||
url = "jdbc:h2:./test;MODE=POSTGRESQL",
|
||||
driver = "org.h2.Driver",
|
||||
) }
|
||||
single<ConfigData>{ ConfigData(
|
||||
)
|
||||
}
|
||||
single<ConfigData> {
|
||||
ConfigData(
|
||||
environment.config.property("hideout.hostname").getString(),
|
||||
jacksonObjectMapper()
|
||||
) }
|
||||
single<IUserRepository>{UserRepository(get())}
|
||||
single<IUserAuthRepository>{UserAuthRepository(get())}
|
||||
single<IUserAuthService>{ UserAuthService(get(),get()) }
|
||||
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<UserService> { UserService(get()) }
|
||||
single<ActivityPubUserService> { ActivityPubUserService(get())}
|
||||
single<ActivityPubUserService> { ActivityPubUserService(get()) }
|
||||
}
|
||||
configureKoin(module)
|
||||
val configData by inject<ConfigData>()
|
||||
|
@ -59,7 +66,7 @@ fun Application.module() {
|
|||
configureSerialization()
|
||||
configureSockets()
|
||||
val activityPubUserService by inject<ActivityPubUserService>()
|
||||
user(userService,activityPubUserService)
|
||||
user(userService, activityPubUserService)
|
||||
login()
|
||||
register(userAuthService)
|
||||
wellKnown(userService)
|
||||
|
|
|
@ -6,7 +6,7 @@ open class Image : Object {
|
|||
|
||||
protected constructor() : super()
|
||||
constructor(type: List<String> = emptyList(), name: String, mediaType: String?, url: String?) : super(
|
||||
type,
|
||||
add(type,"Image"),
|
||||
name
|
||||
) {
|
||||
this.mediaType = mediaType
|
||||
|
|
|
@ -8,7 +8,7 @@ import io.ktor.server.application.*
|
|||
import io.ktor.server.response.*
|
||||
|
||||
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)
|
||||
respondText(activityJson, ContentType.Application.Activity, status)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ class ActivityPubUserService(private val userService: UserService) {
|
|||
val userUrl = "${Config.configData.hostname}/users/$name"
|
||||
return Person(
|
||||
emptyList(),
|
||||
"Icon",
|
||||
userEntity.name,
|
||||
userUrl,
|
||||
name,
|
||||
userEntity.description,
|
||||
|
|
Loading…
Reference in New Issue