mirror of https://github.com/usbharu/Hideout.git
feat: ログを追加
This commit is contained in:
parent
a0fe4ffbd5
commit
c9f86a16e7
|
@ -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<Note>(props[DeliverPostJob.post])
|
||||
val inbox = props[DeliverPostJob.inbox]
|
||||
logger.debug("createNoteJob: actor={}, note={}, inbox={}", actor, note, inbox)
|
||||
httpClient.postAp(
|
||||
urlString = inbox,
|
||||
username = "$actor#pubkey",
|
||||
|
|
|
@ -74,6 +74,7 @@ class ActivityPubServiceImpl(
|
|||
}
|
||||
|
||||
override suspend fun <T : HideoutJob> processActivity(job: JobContextWithProps<T>, hideoutJob: HideoutJob) {
|
||||
logger.debug("processActivity: ${hideoutJob.name}")
|
||||
when (hideoutJob) {
|
||||
ReceiveFollowJob -> activityPubFollowService.receiveFollowJob(job.props as JobProps<ReceiveFollowJob>)
|
||||
DeliverPostJob -> activityPubNoteService.createNoteJob(job.props as JobProps<DeliverPostJob>)
|
||||
|
|
|
@ -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 <J : Job> schedule(job: J,block:ScheduleContext<J>.(J)->Unit) {
|
||||
logger.debug("schedule job={}",job.name)
|
||||
kjob.schedule(job,block)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue