feat: DIに登録

This commit is contained in:
usbharu 2023-04-21 00:14:17 +09:00
parent d91d810e4d
commit 3ccdc81b20
2 changed files with 8 additions and 10 deletions

View File

@ -25,11 +25,6 @@ import io.ktor.client.*
import io.ktor.client.engine.cio.* import io.ktor.client.engine.cio.*
import io.ktor.client.plugins.logging.* import io.ktor.client.plugins.logging.*
import io.ktor.server.application.* import io.ktor.server.application.*
import kjob.core.Job
import kjob.core.KJob
import kjob.core.dsl.JobContextWithProps
import kjob.core.dsl.JobRegisterContext
import kjob.core.dsl.KJobFunctions
import kjob.core.kjob import kjob.core.kjob
import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.Database
import org.koin.ktor.ext.inject import org.koin.ktor.ext.inject
@ -76,15 +71,16 @@ fun Application.parent() {
logger = Logger.DEFAULT logger = Logger.DEFAULT
level = LogLevel.ALL level = LogLevel.ALL
} }
install(httpSignaturePlugin){ install(httpSignaturePlugin) {
keyMap = KtorKeyMap(get()) keyMap = KtorKeyMap(get())
} }
} }
} }
single<ActivityPubFollowService> { ActivityPubFollowServiceImpl(get(), get(), get(),get()) } single<ActivityPubFollowService> { ActivityPubFollowServiceImpl(get(), get(), get(), get()) }
single<ActivityPubService> { ActivityPubServiceImpl(get()) } single<ActivityPubService> { ActivityPubServiceImpl(get(), get()) }
single<UserService> { UserService(get()) } single<UserService> { UserService(get()) }
single<ActivityPubUserService> { ActivityPubUserServiceImpl(get(), get(), get()) } single<ActivityPubUserService> { ActivityPubUserServiceImpl(get(), get(), get()) }
single<ActivityPubNoteService> { ActivityPubNoteServiceImpl(get(), get(), get()) }
} }
@ -101,6 +97,7 @@ fun Application.parent() {
inject<ActivityPubUserService>().value inject<ActivityPubUserService>().value
) )
} }
@Suppress("unused") @Suppress("unused")
fun Application.worker() { fun Application.worker() {
val kJob = kjob(ExposedKJob) { val kJob = kjob(ExposedKJob) {
@ -109,9 +106,9 @@ fun Application.worker() {
val activityPubService = inject<ActivityPubService>().value val activityPubService = inject<ActivityPubService>().value
kJob.register(ReceiveFollowJob){ kJob.register(ReceiveFollowJob) {
execute { execute {
activityPubService.processActivity(this,it) activityPubService.processActivity(this, it)
} }
} }
} }

View File

@ -39,6 +39,7 @@ class PostRepositoryImpl(database: Database, private val idGenerateService: IdGe
} }
return@query PostEntity( return@query PostEntity(
generateId, generateId,
post.userId,
post.overview, post.overview,
post.text, post.text,
post.createdAt, post.createdAt,