diff --git a/src/main/kotlin/dev/usbharu/hideout/Application.kt b/src/main/kotlin/dev/usbharu/hideout/Application.kt index b0c127a0..59b58c4c 100644 --- a/src/main/kotlin/dev/usbharu/hideout/Application.kt +++ b/src/main/kotlin/dev/usbharu/hideout/Application.kt @@ -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 { UserAuthService(get(), get()) } single { UserService(get()) } single { ActivityPubUserService(get(), get(),get()) } + single { ActivityPubService() } + single { HttpClient(CIO) } } configureKoin(module) val configData by inject() @@ -67,5 +68,6 @@ fun Application.module() { login() register(userAuthService) wellKnown(userService) - userActivityPubRouting() + val activityPubService by inject() + userActivityPubRouting(activityPubService) } diff --git a/src/main/kotlin/dev/usbharu/hideout/service/ActivityPubService.kt b/src/main/kotlin/dev/usbharu/hideout/service/ActivityPubService.kt index 565051b6..d26dc981 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/ActivityPubService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/ActivityPubService.kt @@ -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