fix: DIを修正

This commit is contained in:
usbharu 2023-03-30 15:39:48 +09:00
parent 08d36724f5
commit 7e77d8c631
2 changed files with 10 additions and 7 deletions

View File

@ -11,10 +11,9 @@ import dev.usbharu.hideout.repository.IUserRepository
import dev.usbharu.hideout.repository.UserAuthRepository
import dev.usbharu.hideout.repository.UserRepository
import dev.usbharu.hideout.routing.*
import dev.usbharu.hideout.service.ActivityPubUserService
import dev.usbharu.hideout.service.IUserAuthService
import dev.usbharu.hideout.service.UserAuthService
import dev.usbharu.hideout.service.UserService
import dev.usbharu.hideout.service.*
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.server.application.*
import io.ktor.server.auth.*
import io.ktor.util.*
@ -47,6 +46,8 @@ fun Application.module() {
single<IUserAuthService> { UserAuthService(get(), get()) }
single<UserService> { UserService(get()) }
single<ActivityPubUserService> { ActivityPubUserService(get(), get(),get()) }
single<ActivityPubService> { ActivityPubService() }
single<HttpClient> { HttpClient(CIO) }
}
configureKoin(module)
val configData by inject<ConfigData>()
@ -67,5 +68,6 @@ fun Application.module() {
login()
register(userAuthService)
wellKnown(userService)
userActivityPubRouting()
val activityPubService by inject<ActivityPubService>()
userActivityPubRouting(activityPubService)
}

View File

@ -1,8 +1,9 @@
package dev.usbharu.hideout.service
import com.fasterxml.jackson.databind.ObjectMapper
import dev.usbharu.hideout.config.Config
class ActivityPubService(private val objectMapper: ObjectMapper) {
class ActivityPubService() {
enum class ActivityType{
Follow,
@ -10,7 +11,7 @@ class ActivityPubService(private val objectMapper: ObjectMapper) {
}
fun switchApType(json:String):ActivityType{
val typeAsText = objectMapper.readTree(json).get("type").asText()
val typeAsText = Config.configData.objectMapper.readTree(json).get("type").asText()
return when(typeAsText){
"Follow" -> ActivityType.Follow
"Undo" -> ActivityType.Undo