feat: ジョブキューをOWLに切り替え

This commit is contained in:
usbharu 2024-05-04 18:28:01 +09:00
parent 0b29c3356a
commit 3a541fa4b0
35 changed files with 236 additions and 118 deletions

View File

@ -31,22 +31,22 @@ version = "0.0.1"
sourceSets { sourceSets {
create("intTest") { create("intTest") {
test { // test {
compileClasspath += sourceSets.main.get().output compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output runtimeClasspath += sourceSets.main.get().output
kotlin.srcDirs("src/intTest/kotlin") kotlin.srcDirs("src/intTest/kotlin")
java.srcDirs("src/intTest/java") java.srcDirs("src/intTest/java")
resources.srcDirs("src/intTest/resources") resources.srcDirs("src/intTest/resources")
} // }
} }
create("e2eTest") { create("e2eTest") {
test { // test {
compileClasspath += sourceSets.main.get().output compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output runtimeClasspath += sourceSets.main.get().output
kotlin.srcDirs("src/e2eTest/kotlin") kotlin.srcDirs("src/e2eTest/kotlin")
java.srcDirs("src/e2eTest/java") java.srcDirs("src/e2eTest/java")
resources.srcDirs("src/e2eTest/resources") resources.srcDirs("src/e2eTest/resources")
} // }
} }
} }
@ -263,7 +263,7 @@ dependencies {
detekt { detekt {
parallel = true parallel = true
config = files("detekt.yml") config = files("../detekt.yml")
buildUponDefaultConfig = true buildUponDefaultConfig = true
basePath = "${rootDir.absolutePath}/src/main/kotlin" basePath = "${rootDir.absolutePath}/src/main/kotlin"
autoCorrect = true autoCorrect = true
@ -286,14 +286,6 @@ tasks.withType<io.gitlab.arturbosch.detekt.DetektCreateBaselineTask>().configure
exclude("**/org/koin/ksp/generated/**", "**/generated/**") exclude("**/org/koin/ksp/generated/**", "**/generated/**")
} }
configurations.matching { it.name == "detekt" }.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin") {
useVersion("1.9.22")
}
}
}
configurations { configurations {
all { all {
exclude("org.springframework.boot", "spring-boot-starter-logging") exclude("org.springframework.boot", "spring-boot-starter-logging")

View File

@ -19,9 +19,8 @@ package dev.usbharu.hideout.activitypub.service.activity.accept
import dev.usbharu.hideout.activitypub.domain.model.Accept import dev.usbharu.hideout.activitypub.domain.model.Accept
import dev.usbharu.hideout.activitypub.domain.model.Follow import dev.usbharu.hideout.activitypub.domain.model.Follow
import dev.usbharu.hideout.core.domain.model.actor.Actor import dev.usbharu.hideout.core.domain.model.actor.Actor
import dev.usbharu.hideout.core.external.job.DeliverAcceptJob
import dev.usbharu.hideout.core.external.job.DeliverAcceptJobParam import dev.usbharu.hideout.core.external.job.DeliverAcceptJobParam
import dev.usbharu.hideout.core.service.job.JobQueueParentService import dev.usbharu.owl.producer.api.OwlProducer
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
interface ApSendAcceptService { interface ApSendAcceptService {
@ -30,8 +29,7 @@ interface ApSendAcceptService {
@Service @Service
class ApSendAcceptServiceImpl( class ApSendAcceptServiceImpl(
private val jobQueueParentService: JobQueueParentService, private val owlProducer: OwlProducer,
private val deliverAcceptJob: DeliverAcceptJob
) : ApSendAcceptService { ) : ApSendAcceptService {
override suspend fun sendAcceptFollow(actor: Actor, target: Actor) { override suspend fun sendAcceptFollow(actor: Actor, target: Actor) {
val deliverAcceptJobParam = DeliverAcceptJobParam( val deliverAcceptJobParam = DeliverAcceptJobParam(
@ -46,6 +44,6 @@ class ApSendAcceptServiceImpl(
actor.id actor.id
) )
jobQueueParentService.scheduleTypeSafe(deliverAcceptJob, deliverAcceptJobParam) owlProducer.publishTask(deliverAcceptJobParam)
} }
} }

View File

@ -21,9 +21,8 @@ import dev.usbharu.hideout.activitypub.domain.model.Follow
import dev.usbharu.hideout.activitypub.domain.model.Reject import dev.usbharu.hideout.activitypub.domain.model.Reject
import dev.usbharu.hideout.application.config.ApplicationConfig import dev.usbharu.hideout.application.config.ApplicationConfig
import dev.usbharu.hideout.core.domain.model.actor.Actor import dev.usbharu.hideout.core.domain.model.actor.Actor
import dev.usbharu.hideout.core.external.job.DeliverBlockJob
import dev.usbharu.hideout.core.external.job.DeliverBlockJobParam import dev.usbharu.hideout.core.external.job.DeliverBlockJobParam
import dev.usbharu.hideout.core.service.job.JobQueueParentService import dev.usbharu.owl.producer.api.OwlProducer
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
interface APSendBlockService { interface APSendBlockService {
@ -33,8 +32,7 @@ interface APSendBlockService {
@Service @Service
class ApSendBlockServiceImpl( class ApSendBlockServiceImpl(
private val applicationConfig: ApplicationConfig, private val applicationConfig: ApplicationConfig,
private val jobQueueParentService: JobQueueParentService, private val owlProducer: OwlProducer,
private val deliverBlockJob: DeliverBlockJob
) : APSendBlockService { ) : APSendBlockService {
override suspend fun sendBlock(actor: Actor, target: Actor) { override suspend fun sendBlock(actor: Actor, target: Actor) {
val blockJobParam = DeliverBlockJobParam( val blockJobParam = DeliverBlockJobParam(
@ -54,6 +52,6 @@ class ApSendBlockServiceImpl(
), ),
target.inbox target.inbox
) )
jobQueueParentService.scheduleTypeSafe(deliverBlockJob, blockJobParam) owlProducer.publishTask(blockJobParam)
} }
} }

View File

@ -24,9 +24,10 @@ import dev.usbharu.hideout.core.domain.exception.resource.PostNotFoundException
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.domain.model.post.Post import dev.usbharu.hideout.core.domain.model.post.Post
import dev.usbharu.hideout.core.external.job.DeliverPostJob import dev.usbharu.hideout.core.external.job.DeliverPostTask
import dev.usbharu.hideout.core.query.FollowerQueryService import dev.usbharu.hideout.core.query.FollowerQueryService
import dev.usbharu.hideout.core.service.job.JobQueueParentService import dev.usbharu.hideout.core.service.job.JobQueueParentService
import dev.usbharu.owl.producer.api.OwlProducer
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
@ -37,7 +38,8 @@ class ApSendCreateServiceImpl(
private val jobQueueParentService: JobQueueParentService, private val jobQueueParentService: JobQueueParentService,
private val noteQueryService: NoteQueryService, private val noteQueryService: NoteQueryService,
private val applicationConfig: ApplicationConfig, private val applicationConfig: ApplicationConfig,
private val actorRepository: ActorRepository private val actorRepository: ActorRepository,
private val owlProducer: OwlProducer,
) : ApSendCreateService { ) : ApSendCreateService {
override suspend fun createNote(post: Post) { override suspend fun createNote(post: Post) {
logger.info("CREATE Create Local Note ${post.url}") logger.info("CREATE Create Local Note ${post.url}")
@ -56,11 +58,7 @@ class ApSendCreateServiceImpl(
id = "${applicationConfig.url}/create/note/${post.id}" id = "${applicationConfig.url}/create/note/${post.id}"
) )
followers.forEach { followerEntity -> followers.forEach { followerEntity ->
jobQueueParentService.schedule(DeliverPostJob) { owlProducer.publishTask(DeliverPostTask(create, userEntity.url, followerEntity.inbox))
props[DeliverPostJob.actor] = userEntity.url
props[DeliverPostJob.inbox] = followerEntity.inbox
props[DeliverPostJob.create] = objectMapper.writeValueAsString(create)
}
} }
logger.debug("SUCCESS Create Local Note ${post.url}") logger.debug("SUCCESS Create Local Note ${post.url}")

View File

@ -24,10 +24,9 @@ import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
import dev.usbharu.hideout.core.domain.model.actor.Actor import dev.usbharu.hideout.core.domain.model.actor.Actor
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.domain.model.post.Post import dev.usbharu.hideout.core.domain.model.post.Post
import dev.usbharu.hideout.core.external.job.DeliverDeleteJob
import dev.usbharu.hideout.core.external.job.DeliverDeleteJobParam import dev.usbharu.hideout.core.external.job.DeliverDeleteJobParam
import dev.usbharu.hideout.core.query.FollowerQueryService import dev.usbharu.hideout.core.query.FollowerQueryService
import dev.usbharu.hideout.core.service.job.JobQueueParentService import dev.usbharu.owl.producer.api.OwlProducer
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import java.time.Instant import java.time.Instant
@ -38,11 +37,10 @@ interface APSendDeleteService {
@Service @Service
class APSendDeleteServiceImpl( class APSendDeleteServiceImpl(
private val jobQueueParentService: JobQueueParentService,
private val delverDeleteJob: DeliverDeleteJob,
private val followerQueryService: FollowerQueryService, private val followerQueryService: FollowerQueryService,
private val applicationConfig: ApplicationConfig, private val applicationConfig: ApplicationConfig,
private val actorRepository: ActorRepository private val actorRepository: ActorRepository,
private val owlProducer: OwlProducer,
) : APSendDeleteService { ) : APSendDeleteService {
override suspend fun sendDeleteNote(deletedPost: Post) { override suspend fun sendDeleteNote(deletedPost: Post) {
val actor = val actor =
@ -62,7 +60,8 @@ class APSendDeleteServiceImpl(
it.inbox, it.inbox,
actor.id actor.id
) )
jobQueueParentService.scheduleTypeSafe(delverDeleteJob, jobProps)
owlProducer.publishTask(jobProps)
} }
} }

View File

@ -22,16 +22,15 @@ import dev.usbharu.hideout.activitypub.service.common.AbstractActivityPubProcess
import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext
import dev.usbharu.hideout.activitypub.service.common.ActivityType import dev.usbharu.hideout.activitypub.service.common.ActivityType
import dev.usbharu.hideout.application.external.Transaction import dev.usbharu.hideout.application.external.Transaction
import dev.usbharu.hideout.core.external.job.ReceiveFollowJob
import dev.usbharu.hideout.core.external.job.ReceiveFollowJobParam import dev.usbharu.hideout.core.external.job.ReceiveFollowJobParam
import dev.usbharu.hideout.core.service.job.JobQueueParentService import dev.usbharu.owl.producer.api.OwlProducer
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
@Service @Service
class APFollowProcessor( class APFollowProcessor(
transaction: Transaction, transaction: Transaction,
private val jobQueueParentService: JobQueueParentService, private val objectMapper: ObjectMapper,
private val objectMapper: ObjectMapper private val owlProducer: OwlProducer,
) : ) :
AbstractActivityPubProcessor<Follow>(transaction) { AbstractActivityPubProcessor<Follow>(transaction) {
override suspend fun internalProcess(activity: ActivityPubProcessContext<Follow>) { override suspend fun internalProcess(activity: ActivityPubProcessContext<Follow>) {
@ -43,7 +42,7 @@ class APFollowProcessor(
objectMapper.writeValueAsString(activity.activity), objectMapper.writeValueAsString(activity.activity),
activity.activity.apObject activity.activity.apObject
) )
jobQueueParentService.scheduleTypeSafe(ReceiveFollowJob, jobProps) owlProducer.publishTask(jobProps)
} }
override fun isSupported(activityType: ActivityType): Boolean = activityType == ActivityType.Follow override fun isSupported(activityType: ActivityType): Boolean = activityType == ActivityType.Follow

View File

@ -16,12 +16,10 @@
package dev.usbharu.hideout.activitypub.service.activity.follow package dev.usbharu.hideout.activitypub.service.activity.follow
import com.fasterxml.jackson.databind.ObjectMapper
import dev.usbharu.hideout.activitypub.domain.model.Follow import dev.usbharu.hideout.activitypub.domain.model.Follow
import dev.usbharu.hideout.core.external.job.ReceiveFollowJob import dev.usbharu.hideout.core.external.job.ReceiveFollowTask
import dev.usbharu.hideout.core.service.job.JobQueueParentService import dev.usbharu.owl.producer.api.OwlProducer
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
interface APReceiveFollowService { interface APReceiveFollowService {
@ -30,16 +28,11 @@ interface APReceiveFollowService {
@Service @Service
class APReceiveFollowServiceImpl( class APReceiveFollowServiceImpl(
private val jobQueueParentService: JobQueueParentService, private val owlProducer: OwlProducer,
@Qualifier("activitypub") private val objectMapper: ObjectMapper
) : APReceiveFollowService { ) : APReceiveFollowService {
override suspend fun receiveFollow(follow: Follow) { override suspend fun receiveFollow(follow: Follow) {
logger.info("FOLLOW from: {} to: {}", follow.actor, follow.apObject) logger.info("FOLLOW from: {} to: {}", follow.actor, follow.apObject)
jobQueueParentService.schedule(ReceiveFollowJob) { owlProducer.publishTask(ReceiveFollowTask(follow.actor, follow, follow.apObject))
props[ReceiveFollowJob.actor] = follow.actor
props[ReceiveFollowJob.follow] = objectMapper.writeValueAsString(follow)
props[ReceiveFollowJob.targetActor] = follow.apObject
}
return return
} }

View File

@ -16,17 +16,15 @@
package dev.usbharu.hideout.activitypub.service.activity.like package dev.usbharu.hideout.activitypub.service.activity.like
import com.fasterxml.jackson.databind.ObjectMapper
import dev.usbharu.hideout.core.domain.exception.resource.PostNotFoundException import dev.usbharu.hideout.core.domain.exception.resource.PostNotFoundException
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.domain.model.post.PostRepository import dev.usbharu.hideout.core.domain.model.post.PostRepository
import dev.usbharu.hideout.core.domain.model.reaction.Reaction import dev.usbharu.hideout.core.domain.model.reaction.Reaction
import dev.usbharu.hideout.core.external.job.DeliverReactionJob import dev.usbharu.hideout.core.external.job.DeliverReactionTask
import dev.usbharu.hideout.core.external.job.DeliverRemoveReactionJob import dev.usbharu.hideout.core.external.job.DeliverRemoveReactionTask
import dev.usbharu.hideout.core.query.FollowerQueryService import dev.usbharu.hideout.core.query.FollowerQueryService
import dev.usbharu.hideout.core.service.job.JobQueueParentService import dev.usbharu.owl.producer.api.OwlProducer
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
interface APReactionService { interface APReactionService {
@ -36,11 +34,10 @@ interface APReactionService {
@Service @Service
class APReactionServiceImpl( class APReactionServiceImpl(
private val jobQueueParentService: JobQueueParentService,
private val followerQueryService: FollowerQueryService, private val followerQueryService: FollowerQueryService,
private val actorRepository: ActorRepository, private val actorRepository: ActorRepository,
@Qualifier("activitypub") private val objectMapper: ObjectMapper, private val postRepository: PostRepository,
private val postRepository: PostRepository private val owlProducer: OwlProducer,
) : APReactionService { ) : APReactionService {
override suspend fun reaction(like: Reaction) { override suspend fun reaction(like: Reaction) {
val followers = followerQueryService.findFollowersById(like.actorId) val followers = followerQueryService.findFollowersById(like.actorId)
@ -48,13 +45,15 @@ class APReactionServiceImpl(
val post = val post =
postRepository.findById(like.postId) ?: throw PostNotFoundException.withId(like.postId) postRepository.findById(like.postId) ?: throw PostNotFoundException.withId(like.postId)
followers.forEach { follower -> followers.forEach { follower ->
jobQueueParentService.schedule(DeliverReactionJob) { owlProducer.publishTask(
props[DeliverReactionJob.actor] = user.url DeliverReactionTask(
props[DeliverReactionJob.reaction] = "" actor = user.url,
props[DeliverReactionJob.inbox] = follower.inbox reaction = "",
props[DeliverReactionJob.postUrl] = post.url inbox = follower.inbox,
props[DeliverReactionJob.id] = post.id.toString() postUrl = post.url,
} id = post.id
)
)
} }
} }
@ -64,12 +63,14 @@ class APReactionServiceImpl(
val post = val post =
postRepository.findById(like.postId) ?: throw PostNotFoundException.withId(like.postId) postRepository.findById(like.postId) ?: throw PostNotFoundException.withId(like.postId)
followers.forEach { follower -> followers.forEach { follower ->
jobQueueParentService.schedule(DeliverRemoveReactionJob) { owlProducer.publishTask(
props[DeliverRemoveReactionJob.actor] = user.url DeliverRemoveReactionTask(
props[DeliverRemoveReactionJob.inbox] = follower.inbox actor = user.url,
props[DeliverRemoveReactionJob.id] = post.id.toString() inbox = follower.inbox,
props[DeliverRemoveReactionJob.like] = objectMapper.writeValueAsString(like) id = post.id,
} reaction = like
)
)
} }
} }
} }

View File

@ -20,16 +20,14 @@ import dev.usbharu.hideout.activitypub.domain.model.Follow
import dev.usbharu.hideout.activitypub.domain.model.Reject import dev.usbharu.hideout.activitypub.domain.model.Reject
import dev.usbharu.hideout.application.config.ApplicationConfig import dev.usbharu.hideout.application.config.ApplicationConfig
import dev.usbharu.hideout.core.domain.model.actor.Actor import dev.usbharu.hideout.core.domain.model.actor.Actor
import dev.usbharu.hideout.core.external.job.DeliverRejectJob
import dev.usbharu.hideout.core.external.job.DeliverRejectJobParam import dev.usbharu.hideout.core.external.job.DeliverRejectJobParam
import dev.usbharu.hideout.core.service.job.JobQueueParentService import dev.usbharu.owl.producer.api.OwlProducer
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
@Service @Service
class ApSendRejectServiceImpl( class ApSendRejectServiceImpl(
private val applicationConfig: ApplicationConfig, private val applicationConfig: ApplicationConfig,
private val jobQueueParentService: JobQueueParentService, private val owlProducer: OwlProducer,
private val deliverRejectJob: DeliverRejectJob
) : ApSendRejectService { ) : ApSendRejectService {
override suspend fun sendRejectFollow(actor: Actor, target: Actor) { override suspend fun sendRejectFollow(actor: Actor, target: Actor) {
val deliverRejectJobParam = DeliverRejectJobParam( val deliverRejectJobParam = DeliverRejectJobParam(
@ -42,6 +40,6 @@ class ApSendRejectServiceImpl(
actor.id actor.id
) )
jobQueueParentService.scheduleTypeSafe(deliverRejectJob, deliverRejectJobParam) owlProducer.publishTask(deliverRejectJobParam)
} }
} }

View File

@ -21,17 +21,15 @@ import dev.usbharu.hideout.activitypub.domain.model.Follow
import dev.usbharu.hideout.activitypub.domain.model.Undo import dev.usbharu.hideout.activitypub.domain.model.Undo
import dev.usbharu.hideout.application.config.ApplicationConfig import dev.usbharu.hideout.application.config.ApplicationConfig
import dev.usbharu.hideout.core.domain.model.actor.Actor import dev.usbharu.hideout.core.domain.model.actor.Actor
import dev.usbharu.hideout.core.external.job.DeliverUndoJob
import dev.usbharu.hideout.core.external.job.DeliverUndoJobParam import dev.usbharu.hideout.core.external.job.DeliverUndoJobParam
import dev.usbharu.hideout.core.service.job.JobQueueParentService import dev.usbharu.owl.producer.api.OwlProducer
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import java.time.Instant import java.time.Instant
@Service @Service
class APSendUndoServiceImpl( class APSendUndoServiceImpl(
private val jobQueueParentService: JobQueueParentService, private val applicationConfig: ApplicationConfig,
private val deliverUndoJob: DeliverUndoJob, private val owlProducer: OwlProducer,
private val applicationConfig: ApplicationConfig
) : APSendUndoService { ) : APSendUndoService {
override suspend fun sendUndoFollow(actor: Actor, target: Actor) { override suspend fun sendUndoFollow(actor: Actor, target: Actor) {
val deliverUndoJobParam = DeliverUndoJobParam( val deliverUndoJobParam = DeliverUndoJobParam(
@ -48,7 +46,7 @@ class APSendUndoServiceImpl(
actor.id actor.id
) )
jobQueueParentService.scheduleTypeSafe(deliverUndoJob, deliverUndoJobParam) owlProducer.publishTask(deliverUndoJobParam)
} }
override suspend fun sendUndoBlock(actor: Actor, target: Actor) { override suspend fun sendUndoBlock(actor: Actor, target: Actor) {
@ -67,6 +65,6 @@ class APSendUndoServiceImpl(
actor.id actor.id
) )
jobQueueParentService.scheduleTypeSafe(deliverUndoJob, deliverUndoJobParam) owlProducer.publishTask(deliverUndoJobParam)
} }
} }

View File

@ -19,9 +19,9 @@ package dev.usbharu.hideout.activitypub.service.common
import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import dev.usbharu.hideout.activitypub.domain.exception.JsonParseException import dev.usbharu.hideout.activitypub.domain.exception.JsonParseException
import dev.usbharu.hideout.core.external.job.InboxJob import dev.usbharu.hideout.core.external.job.InboxTask
import dev.usbharu.hideout.core.service.job.JobQueueParentService
import dev.usbharu.httpsignature.common.HttpRequest import dev.usbharu.httpsignature.common.HttpRequest
import dev.usbharu.owl.producer.api.OwlProducer
import org.slf4j.Logger import org.slf4j.Logger
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.annotation.Qualifier
@ -41,7 +41,7 @@ interface APService {
@Service @Service
class APServiceImpl( class APServiceImpl(
@Qualifier("activitypub") private val objectMapper: ObjectMapper, @Qualifier("activitypub") private val objectMapper: ObjectMapper,
private val jobQueueParentService: JobQueueParentService private val owlProducer: OwlProducer,
) : APService { ) : APService {
val logger: Logger = LoggerFactory.getLogger(APServiceImpl::class.java) val logger: Logger = LoggerFactory.getLogger(APServiceImpl::class.java)
@ -90,13 +90,14 @@ class APServiceImpl(
map: Map<String, List<String>> map: Map<String, List<String>>
) { ) {
logger.debug("process activity: {}", type) logger.debug("process activity: {}", type)
jobQueueParentService.schedule(InboxJob) { owlProducer.publishTask(
props[it.json] = json InboxTask(
props[it.type] = type.name json,
val writeValueAsString = objectMapper.writeValueAsString(httpRequest) type,
props[it.httpRequest] = writeValueAsString httpRequest,
props[it.headers] = objectMapper.writeValueAsString(map) map
} )
)
return return
} }
} }

View File

@ -46,4 +46,4 @@ enum class ActivityType {
Update, Update,
View, View,
Other Other
} }

View File

@ -71,4 +71,4 @@ enum class ActivityVocabulary {
Tombstone, Tombstone,
Video, Video,
Mention, Mention,
} }

View File

@ -72,4 +72,4 @@ enum class ExtendedActivityVocabulary {
Video, Video,
Mention, Mention,
Emoji Emoji
} }

View File

@ -18,4 +18,4 @@ package dev.usbharu.hideout.activitypub.service.common
enum class ExtendedVocabulary { enum class ExtendedVocabulary {
Emoji Emoji
} }

View File

@ -19,6 +19,7 @@ package dev.usbharu.hideout.core.external.job
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.activitypub.domain.model.Accept import dev.usbharu.hideout.activitypub.domain.model.Accept
import dev.usbharu.owl.common.task.Task
import kjob.core.dsl.ScheduleContext import kjob.core.dsl.ScheduleContext
import kjob.core.job.JobProps import kjob.core.job.JobProps
import org.springframework.stereotype.Component import org.springframework.stereotype.Component
@ -26,8 +27,8 @@ import org.springframework.stereotype.Component
data class DeliverAcceptJobParam( data class DeliverAcceptJobParam(
val accept: Accept, val accept: Accept,
val inbox: String, val inbox: String,
val signer: Long val signer: Long,
) ) : Task()
@Component @Component
class DeliverAcceptJob(private val objectMapper: ObjectMapper) : class DeliverAcceptJob(private val objectMapper: ObjectMapper) :

View File

@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.activitypub.domain.model.Block import dev.usbharu.hideout.activitypub.domain.model.Block
import dev.usbharu.hideout.activitypub.domain.model.Reject import dev.usbharu.hideout.activitypub.domain.model.Reject
import dev.usbharu.owl.common.task.Task
import kjob.core.dsl.ScheduleContext import kjob.core.dsl.ScheduleContext
import kjob.core.job.JobProps import kjob.core.job.JobProps
import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.annotation.Qualifier
@ -37,8 +38,8 @@ data class DeliverBlockJobParam(
val signer: Long, val signer: Long,
val block: Block, val block: Block,
val reject: Reject, val reject: Reject,
val inbox: String val inbox: String,
) ) : Task()
/** /**
* ブロックアクティビティ配送のジョブ * ブロックアクティビティ配送のジョブ

View File

@ -19,6 +19,7 @@ package dev.usbharu.hideout.core.external.job
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.activitypub.domain.model.Delete import dev.usbharu.hideout.activitypub.domain.model.Delete
import dev.usbharu.owl.common.task.Task
import kjob.core.dsl.ScheduleContext import kjob.core.dsl.ScheduleContext
import kjob.core.job.JobProps import kjob.core.job.JobProps
import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.annotation.Qualifier
@ -27,8 +28,8 @@ import org.springframework.stereotype.Component
data class DeliverDeleteJobParam( data class DeliverDeleteJobParam(
val delete: Delete, val delete: Delete,
val inbox: String, val inbox: String,
val signer: Long val signer: Long,
) ) : Task()
@Component @Component
class DeliverDeleteJob(@Qualifier("activitypub") private val objectMapper: ObjectMapper) : class DeliverDeleteJob(@Qualifier("activitypub") private val objectMapper: ObjectMapper) :

View File

@ -0,0 +1,26 @@
/*
* Copyright (C) 2024 usbharu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.usbharu.hideout.core.external.job
import dev.usbharu.hideout.activitypub.domain.model.Create
import dev.usbharu.owl.common.task.Task
data class DeliverPostTask(
val create: Create,
val inbox: String,
val actor: String,
) : Task()

View File

@ -0,0 +1,27 @@
/*
* Copyright (C) 2024 usbharu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.usbharu.hideout.core.external.job
import dev.usbharu.owl.common.task.Task
data class DeliverReactionTask(
val actor: String,
val reaction: String,
val inbox: String,
val postUrl: String,
val id: Long,
) : Task()

View File

@ -19,6 +19,7 @@ package dev.usbharu.hideout.core.external.job
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.activitypub.domain.model.Reject import dev.usbharu.hideout.activitypub.domain.model.Reject
import dev.usbharu.owl.common.task.Task
import kjob.core.dsl.ScheduleContext import kjob.core.dsl.ScheduleContext
import kjob.core.job.JobProps import kjob.core.job.JobProps
import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.annotation.Qualifier
@ -27,8 +28,8 @@ import org.springframework.stereotype.Component
data class DeliverRejectJobParam( data class DeliverRejectJobParam(
val reject: Reject, val reject: Reject,
val inbox: String, val inbox: String,
val signer: Long val signer: Long,
) ) : Task()
@Component @Component
class DeliverRejectJob(@Qualifier("activitypub") private val objectMapper: ObjectMapper) : class DeliverRejectJob(@Qualifier("activitypub") private val objectMapper: ObjectMapper) :

View File

@ -0,0 +1,27 @@
/*
* Copyright (C) 2024 usbharu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.usbharu.hideout.core.external.job
import dev.usbharu.hideout.core.domain.model.reaction.Reaction
import dev.usbharu.owl.common.task.Task
data class DeliverRemoveReactionTask(
val actor: String,
val inbox: String,
val id: Long,
val reaction: Reaction,
) : Task()

View File

@ -19,6 +19,7 @@ package dev.usbharu.hideout.core.external.job
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import dev.usbharu.hideout.activitypub.domain.model.Undo import dev.usbharu.hideout.activitypub.domain.model.Undo
import dev.usbharu.owl.common.task.Task
import kjob.core.dsl.ScheduleContext import kjob.core.dsl.ScheduleContext
import kjob.core.job.JobProps import kjob.core.job.JobProps
import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.annotation.Qualifier
@ -27,8 +28,8 @@ import org.springframework.stereotype.Component
data class DeliverUndoJobParam( data class DeliverUndoJobParam(
val undo: Undo, val undo: Undo,
val inbox: String, val inbox: String,
val signer: Long val signer: Long,
) ) : Task()
@Component @Component
class DeliverUndoJob(@Qualifier("activitypub") private val objectMapper: ObjectMapper) : class DeliverUndoJob(@Qualifier("activitypub") private val objectMapper: ObjectMapper) :

View File

@ -17,6 +17,7 @@
package dev.usbharu.hideout.core.external.job package dev.usbharu.hideout.core.external.job
import dev.usbharu.hideout.activitypub.service.common.ActivityType import dev.usbharu.hideout.activitypub.service.common.ActivityType
import dev.usbharu.owl.common.task.Task
import kjob.core.Job import kjob.core.Job
import kjob.core.Prop import kjob.core.Prop
import kjob.core.dsl.ScheduleContext import kjob.core.dsl.ScheduleContext
@ -32,8 +33,8 @@ abstract class HideoutJob<out T, out R : HideoutJob<T, R>>(name: String) : Job(n
data class ReceiveFollowJobParam( data class ReceiveFollowJobParam(
val actor: String, val actor: String,
val follow: String, val follow: String,
val targetActor: String val targetActor: String,
) ) : Task()
@Component @Component
object ReceiveFollowJob : HideoutJob<ReceiveFollowJobParam, ReceiveFollowJob>("ReceiveFollowJob") { object ReceiveFollowJob : HideoutJob<ReceiveFollowJobParam, ReceiveFollowJob>("ReceiveFollowJob") {

View File

@ -0,0 +1,28 @@
/*
* Copyright (C) 2024 usbharu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.usbharu.hideout.core.external.job
import dev.usbharu.hideout.activitypub.service.common.ActivityType
import dev.usbharu.httpsignature.common.HttpRequest
import dev.usbharu.owl.common.task.Task
data class InboxTask(
val json: String,
val type: ActivityType,
val httpRequest: HttpRequest,
val headers: Map<String, List<String>>,
) : Task()

View File

@ -0,0 +1,26 @@
/*
* Copyright (C) 2024 usbharu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.usbharu.hideout.core.external.job
import dev.usbharu.hideout.activitypub.domain.model.Follow
import dev.usbharu.owl.common.task.Task
data class ReceiveFollowTask(
val actor: String,
val follow: Follow,
val targetActor: String,
) : Task()

View File

@ -18,6 +18,7 @@ package dev.usbharu.hideout.core.service.job
import dev.usbharu.hideout.core.external.job.HideoutJob import dev.usbharu.hideout.core.external.job.HideoutJob
@Deprecated("use owl")
interface JobProcessor<in T, out R : HideoutJob<@UnsafeVariance T, R>> { interface JobProcessor<in T, out R : HideoutJob<@UnsafeVariance T, R>> {
suspend fun process(param: @UnsafeVariance T) suspend fun process(param: @UnsafeVariance T)
fun job(): R fun job(): R

View File

@ -22,6 +22,7 @@ import kjob.core.dsl.ScheduleContext
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
@Service @Service
@Deprecated("use owl producer")
interface JobQueueParentService { interface JobQueueParentService {
fun init(jobDefines: List<Job>) fun init(jobDefines: List<Job>)

View File

@ -22,6 +22,7 @@ import dev.usbharu.hideout.core.external.job.HideoutJob as HJ
import kjob.core.dsl.JobContextWithProps as JCWP import kjob.core.dsl.JobContextWithProps as JCWP
import kjob.core.dsl.JobRegisterContext as JRC import kjob.core.dsl.JobRegisterContext as JRC
@Deprecated("use owl")
@Service @Service
interface JobQueueWorkerService { interface JobQueueWorkerService {
fun <T, R : HJ<T, R>> init( fun <T, R : HJ<T, R>> init(

View File

@ -38,7 +38,7 @@ class AccountNotFoundException : ClientException {
) : super(message, cause, enableSuppression, writableStackTrace, response) ) : super(message, cause, enableSuppression, writableStackTrace, response)
fun getTypedResponse(): MastodonApiErrorResponse<NotFoundResponse> = fun getTypedResponse(): MastodonApiErrorResponse<NotFoundResponse> =
response response as MastodonApiErrorResponse<NotFoundResponse>
companion object { companion object {
fun ofId(id: Long): AccountNotFoundException = AccountNotFoundException( fun ofId(id: Long): AccountNotFoundException = AccountNotFoundException(

View File

@ -40,7 +40,7 @@ class StatusNotFoundException : ClientException {
) : super(message, cause, enableSuppression, writableStackTrace, response) ) : super(message, cause, enableSuppression, writableStackTrace, response)
fun getTypedResponse(): MastodonApiErrorResponse<NotFoundResponse> = fun getTypedResponse(): MastodonApiErrorResponse<NotFoundResponse> =
response response as MastodonApiErrorResponse<NotFoundResponse>
companion object { companion object {
fun ofId(id: Long): StatusNotFoundException = StatusNotFoundException( fun ofId(id: Long): StatusNotFoundException = StatusNotFoundException(

View File

@ -16,9 +16,9 @@
package dev.usbharu.hideout.mastodon.interfaces.api.status package dev.usbharu.hideout.mastodon.interfaces.api.status
import Status
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
import dev.usbharu.hideout.core.domain.model.post.Visibility import dev.usbharu.hideout.core.domain.model.post.Visibility
import dev.usbharu.hideout.domain.mastodon.model.generated.Status
import dev.usbharu.hideout.domain.mastodon.model.generated.StatusesRequestPoll import dev.usbharu.hideout.domain.mastodon.model.generated.StatusesRequestPoll
import dev.usbharu.hideout.mastodon.interfaces.api.status.StatusesRequest.Visibility.* import dev.usbharu.hideout.mastodon.interfaces.api.status.StatusesRequest.Visibility.*

View File

@ -55,11 +55,9 @@ class APReactionServiceImplTest {
onBlocking { findById(eq(user.id)) }.doReturn(user) onBlocking { findById(eq(user.id)) }.doReturn(user)
} }
val apReactionServiceImpl = APReactionServiceImpl( val apReactionServiceImpl = APReactionServiceImpl(
jobQueueParentService = jobQueueParentService,
actorRepository = actorRepository, actorRepository = actorRepository,
followerQueryService = followerQueryService, followerQueryService = followerQueryService,
postRepository = postQueryService, postRepository = postQueryService,
objectMapper = objectMapper
) )
apReactionServiceImpl.reaction( apReactionServiceImpl.reaction(

View File

@ -13,4 +13,6 @@ dependencyResolutionManagement {
from(files("../libs.versions.toml")) from(files("../libs.versions.toml"))
} }
} }
} }
includeBuild("../hideout-core")

View File

@ -4,7 +4,7 @@ kotlin = "1.9.23"
ktor = "2.3.9" ktor = "2.3.9"
exposed = "0.49.0" exposed = "0.49.0"
javacv-ffmpeg = "6.1.1-1.5.10" javacv-ffmpeg = "6.1.1-1.5.10"
detekt = "1.23.5" detekt = "1.23.6"
coroutines = "1.8.0" coroutines = "1.8.0"
swagger = "2.2.6" swagger = "2.2.6"
serialization = "1.6.3" serialization = "1.6.3"