mirror of https://github.com/usbharu/Hideout.git
feat: TimelinePostCreateSubscriberが機能するように
This commit is contained in:
parent
88775f50fe
commit
5320be6c9a
|
@ -66,4 +66,5 @@ tasks.register("run") {
|
|||
|
||||
springBoot {
|
||||
mainClass = "dev.usbharu.hideout.SpringApplicationKt"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:16
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
POSTGRES_USER: "postgres"
|
||||
POSTGRES_PASSWORD: "password"
|
||||
POSTGRES_DB: "hideout"
|
|
@ -0,0 +1,4 @@
|
|||
package dev.usbharu.hideout.core.application.domainevent.subscribers
|
||||
|
||||
interface Subscriber {
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package dev.usbharu.hideout.core.application.domainevent.subscribers
|
||||
|
||||
import org.springframework.boot.ApplicationArguments
|
||||
import org.springframework.boot.ApplicationRunner
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class SubscriberRunner(subscribers:List<Subscriber>) : ApplicationRunner {
|
||||
override fun run(args: ApplicationArguments?) {
|
||||
|
||||
}
|
||||
}
|
|
@ -2,16 +2,23 @@ package dev.usbharu.hideout.core.application.domainevent.subscribers
|
|||
|
||||
import dev.usbharu.hideout.core.domain.event.post.PostEvent
|
||||
import dev.usbharu.hideout.core.domain.event.post.PostEventBody
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.context.annotation.Scope
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class TimelinePostCreateSubscriber(domainEventSubscriber: DomainEventSubscriber) {
|
||||
class TimelinePostCreateSubscriber(domainEventSubscriber: DomainEventSubscriber) :Subscriber{
|
||||
init {
|
||||
domainEventSubscriber.subscribe<PostEventBody>(PostEvent.CREATE.eventName) {
|
||||
val post = it.body.getPost()
|
||||
val actor = it.body.getActor()
|
||||
|
||||
println(post.toString())
|
||||
logger.info("New Post! : {}",post)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
companion object{
|
||||
private val logger = LoggerFactory.getLogger(TimelinePostCreateSubscriber::class.java)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -244,6 +244,30 @@ class Post(
|
|||
)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Post(" +
|
||||
"id=$id, " +
|
||||
"createdAt=$createdAt, " +
|
||||
"url=$url, " +
|
||||
"repostId=$repostId, " +
|
||||
"replyId=$replyId, " +
|
||||
"apId=$apId, " +
|
||||
"actorId=$actorId, " +
|
||||
"visibility=$visibility, " +
|
||||
"visibleActors=$visibleActors, " +
|
||||
"content=$content, " +
|
||||
"overview=$overview, " +
|
||||
"sensitive=$sensitive, " +
|
||||
"text='$text', " +
|
||||
"emojiIds=$emojiIds, " +
|
||||
"mediaIds=$mediaIds, " +
|
||||
"deleted=$deleted, " +
|
||||
"hide=$hide, " +
|
||||
"moveTo=$moveTo" +
|
||||
")"
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
@Suppress("LongParameterList")
|
||||
fun create(
|
||||
|
|
|
@ -24,9 +24,9 @@ spring:
|
|||
default-property-inclusion: always
|
||||
datasource:
|
||||
driver-class-name: org.postgresql.Driver
|
||||
url: "jdbc:postgresql:hideout3"
|
||||
url: "jdbc:postgresql:hideout"
|
||||
username: "postgres"
|
||||
password: ""
|
||||
password: "password"
|
||||
data:
|
||||
mongodb:
|
||||
auto-index-creation: true
|
||||
|
|
|
@ -56,6 +56,8 @@ create table if not exists actors
|
|||
move_to bigint null default null,
|
||||
emojis varchar(3000) not null default '',
|
||||
deleted boolean not null default false,
|
||||
icon bigint null,
|
||||
banner bigint null,
|
||||
unique ("name", "domain"),
|
||||
constraint fk_actors_instance__id foreign key ("instance") references instance (id) on delete restrict on update restrict,
|
||||
constraint fk_actors_actors__move_to foreign key ("move_to") references actors (id) on delete restrict on update restrict
|
||||
|
@ -91,6 +93,13 @@ create table if not exists media
|
|||
mime_type varchar(255) not null,
|
||||
description varchar(4000) null
|
||||
);
|
||||
|
||||
alter table actors
|
||||
add constraint fk_actors_media__icon foreign key ("icon") references media (id) on delete cascade on update cascade;
|
||||
alter table actors
|
||||
add constraint fk_actors_media__banner foreign key ("banner") references media (id) on delete cascade on update cascade;
|
||||
|
||||
|
||||
create table if not exists posts
|
||||
(
|
||||
id bigint primary key,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="TRACE">
|
||||
<Root level="INFO">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
<Logger name="dev.usbharu.owl.broker.service.QueuedTaskAssignerImpl" level="TRACE"/>
|
||||
|
|
|
@ -19,10 +19,18 @@ repositories {
|
|||
mavenCentral()
|
||||
}
|
||||
|
||||
configurations {
|
||||
all {
|
||||
exclude("org.springframework.boot", "spring-boot-starter-logging")
|
||||
exclude("ch.qos.logback", "logback-classic")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
implementation("org.springframework.boot:spring-boot-starter-security")
|
||||
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
|
||||
implementation("org.springframework.boot:spring-boot-starter-log4j2")
|
||||
|
||||
implementation("dev.usbharu:hideout-core:0.0.1")
|
||||
|
||||
|
@ -67,3 +75,4 @@ sourceSets.main {
|
|||
"$buildDir/generated/sources/mastodon/src/main/kotlin"
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import dev.usbharu.hideout.mastodon.query.StatusQuery
|
|||
import dev.usbharu.hideout.mastodon.query.StatusQueryService
|
||||
import org.jetbrains.exposed.sql.ResultRow
|
||||
import org.jetbrains.exposed.sql.andWhere
|
||||
import org.jetbrains.exposed.sql.leftJoin
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.net.URI
|
||||
|
@ -120,7 +121,7 @@ class StatusQueryServiceImpl : StatusQueryService {
|
|||
val map = Posts
|
||||
.leftJoin(PostsMedia)
|
||||
.leftJoin(Actors)
|
||||
.leftJoin(Media)
|
||||
.leftJoin(Media,{PostsMedia.mediaId},{Media.id})
|
||||
.selectAll()
|
||||
.where { Posts.id eq id }
|
||||
.groupBy { it[Posts.id] }
|
||||
|
|
Loading…
Reference in New Issue