feat: Owlの設定を追加

This commit is contained in:
usbharu 2024-11-09 09:03:01 +09:00
parent 22bd24304c
commit 90d28ee8a1
Signed by: usbharu
GPG Key ID: 95CBCF7046307B77
6 changed files with 77 additions and 0 deletions

View File

@ -17,6 +17,9 @@ version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url = uri("https://git.usbharu.dev/api/packages/usbharu/maven")
}
}
dependencies {
@ -26,6 +29,9 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation(libs.bundles.jackson)
implementation(libs.owl.producer.api)
implementation(libs.owl.producer.embedded)
implementation(libs.owl.common.serialize.jackson)
}
tasks.test {

View File

@ -0,0 +1,29 @@
package dev.usbharu.hideout.activitypub.config
import com.fasterxml.jackson.databind.ObjectMapper
import dev.usbharu.owl.common.property.*
import dev.usbharu.owl.producer.api.OWL
import dev.usbharu.owl.producer.api.OwlProducer
import dev.usbharu.owl.producer.embedded.EMBEDDED
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@Configuration
class OwlConfig {
@Bean
fun owlProducer(objectMapper: ObjectMapper): OwlProducer {
return OWL(EMBEDDED) {
this.propertySerializerFactory = CustomPropertySerializerFactory(
setOf(
IntegerPropertySerializer(),
StringPropertyValueSerializer(),
DoublePropertySerializer(),
BooleanPropertySerializer(),
LongPropertySerializer(),
FloatPropertySerializer(),
ObjectPropertySerializer(objectMapper),
)
)
}
}
}

View File

@ -0,0 +1,7 @@
package dev.usbharu.hideout.activitypub.domain.shared.jobqueue
import dev.usbharu.hideout.activitypub.domain.task.Task
interface TaskPublisher {
suspend fun publish(task: Task<*>)
}

View File

@ -0,0 +1,15 @@
package dev.usbharu.hideout.activitypub.domain.task
import dev.usbharu.hideout.core.domain.model.support.domain.Domain
import dev.usbharu.owl.common.task.Task
import java.time.Instant
class Task<out T : TaskBody>(
val id: String,
val name: String,
val publishedOn: Instant,
val body: T,
val domain: Domain
) : Task() {
}

View File

@ -0,0 +1,7 @@
package dev.usbharu.hideout.activitypub.domain.task
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
abstract class TaskBody(private val map: Map<String, Any?>, val principal: Principal) {
fun toMap(): Map<String, Any?> = map
}

View File

@ -0,0 +1,13 @@
package dev.usbharu.hideout.activitypub.infrastructure.owl
import dev.usbharu.hideout.activitypub.domain.shared.jobqueue.TaskPublisher
import dev.usbharu.hideout.activitypub.domain.task.Task
import dev.usbharu.owl.producer.api.OwlProducer
import org.springframework.stereotype.Service
@Service
class OwlTaskPublisher(private val owlProducer: OwlProducer) : TaskPublisher {
override suspend fun publish(task: Task<*>) {
owlProducer.publishTask(task)
}
}