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

View File

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