From 6665481c6a5560f7dcbf4433ff3798bcbdf75bb4 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 21 Apr 2023 20:52:02 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=83=AD=E3=82=B0=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hideout/service/activitypub/ActivityPubNoteServiceImpl.kt | 4 ++++ .../hideout/service/activitypub/ActivityPubServiceImpl.kt | 1 + .../usbharu/hideout/service/job/KJobJobQueueParentService.kt | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubNoteServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubNoteServiceImpl.kt index e9a9f1d9..f5a76bb3 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubNoteServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubNoteServiceImpl.kt @@ -10,6 +10,7 @@ import dev.usbharu.hideout.service.impl.UserService import dev.usbharu.hideout.service.job.JobQueueParentService import io.ktor.client.* import kjob.core.job.JobProps +import org.slf4j.LoggerFactory class ActivityPubNoteServiceImpl( private val httpClient: HttpClient, @@ -17,6 +18,8 @@ class ActivityPubNoteServiceImpl( private val userService: UserService ) : ActivityPubNoteService { + private val logger = LoggerFactory.getLogger(this::class.java) + override suspend fun createNote(post: PostEntity) { val followers = userService.findFollowersById(post.userId) val userEntity = userService.findById(post.userId) @@ -35,6 +38,7 @@ class ActivityPubNoteServiceImpl( val actor = props[DeliverPostJob.actor] val note = Config.configData.objectMapper.readValue(props[DeliverPostJob.post]) val inbox = props[DeliverPostJob.inbox] + logger.debug("createNoteJob: actor={}, note={}, inbox={}", actor, note, inbox) httpClient.postAp( urlString = inbox, username = "$actor#pubkey", diff --git a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubServiceImpl.kt index 7fffacb8..e86f967f 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/activitypub/ActivityPubServiceImpl.kt @@ -74,6 +74,7 @@ class ActivityPubServiceImpl( } override suspend fun processActivity(job: JobContextWithProps, hideoutJob: HideoutJob) { + logger.debug("processActivity: ${hideoutJob.name}") when (hideoutJob) { ReceiveFollowJob -> activityPubFollowService.receiveFollowJob(job.props as JobProps) DeliverPostJob -> activityPubNoteService.createNoteJob(job.props as JobProps) diff --git a/src/main/kotlin/dev/usbharu/hideout/service/job/KJobJobQueueParentService.kt b/src/main/kotlin/dev/usbharu/hideout/service/job/KJobJobQueueParentService.kt index 1f4178b5..6324fde7 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/job/KJobJobQueueParentService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/job/KJobJobQueueParentService.kt @@ -6,9 +6,12 @@ import kjob.core.KJob import kjob.core.dsl.ScheduleContext import kjob.core.kjob import org.jetbrains.exposed.sql.Database +import org.slf4j.LoggerFactory class KJobJobQueueParentService(private val database: Database) : JobQueueParentService { + private val logger = LoggerFactory.getLogger(this::class.java) + val kjob: KJob = kjob(ExposedKJob) { connectionDatabase = database isWorker = false @@ -19,6 +22,7 @@ class KJobJobQueueParentService(private val database: Database) : JobQueueParent } override suspend fun schedule(job: J,block:ScheduleContext.(J)->Unit) { + logger.debug("schedule job={}",job.name) kjob.schedule(job,block) } }