mirror of https://github.com/usbharu/Hideout.git
feat: Owlの設定を追加
This commit is contained in:
parent
22bd24304c
commit
90d28ee8a1
|
@ -17,6 +17,9 @@ version = "1.0-SNAPSHOT"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url = uri("https://git.usbharu.dev/api/packages/usbharu/maven")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -26,6 +29,9 @@ dependencies {
|
||||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-security")
|
implementation("org.springframework.boot:spring-boot-starter-security")
|
||||||
implementation(libs.bundles.jackson)
|
implementation(libs.bundles.jackson)
|
||||||
|
implementation(libs.owl.producer.api)
|
||||||
|
implementation(libs.owl.producer.embedded)
|
||||||
|
implementation(libs.owl.common.serialize.jackson)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
|
|
|
@ -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),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<*>)
|
||||||
|
}
|
|
@ -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() {
|
||||||
|
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue