diff --git a/hideout-activitypub/build.gradle.kts b/hideout-activitypub/build.gradle.kts index 33dd538f..0694c0d5 100644 --- a/hideout-activitypub/build.gradle.kts +++ b/hideout-activitypub/build.gradle.kts @@ -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 { diff --git a/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/config/OwlConfig.kt b/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/config/OwlConfig.kt new file mode 100644 index 00000000..615be159 --- /dev/null +++ b/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/config/OwlConfig.kt @@ -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), + ) + ) + } + } +} \ No newline at end of file diff --git a/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/shared/jobqueue/TaskPublisher.kt b/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/shared/jobqueue/TaskPublisher.kt new file mode 100644 index 00000000..1c0c33b4 --- /dev/null +++ b/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/shared/jobqueue/TaskPublisher.kt @@ -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<*>) +} \ No newline at end of file diff --git a/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/task/Task.kt b/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/task/Task.kt new file mode 100644 index 00000000..77ab78c7 --- /dev/null +++ b/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/task/Task.kt @@ -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( + val id: String, + val name: String, + val publishedOn: Instant, + val body: T, + val domain: Domain +) : Task() { + +} \ No newline at end of file diff --git a/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/task/TaskBody.kt b/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/task/TaskBody.kt new file mode 100644 index 00000000..c0049b1d --- /dev/null +++ b/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/task/TaskBody.kt @@ -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, val principal: Principal) { + fun toMap(): Map = map +} \ No newline at end of file diff --git a/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/owl/OwlTaskPublisher.kt b/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/owl/OwlTaskPublisher.kt new file mode 100644 index 00000000..a641d786 --- /dev/null +++ b/hideout-activitypub/src/main/kotlin/dev/usbharu/hideout/activitypub/infrastructure/owl/OwlTaskPublisher.kt @@ -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) + } +} \ No newline at end of file