From d5805089f5f8f561df17666ea0e416056777f7ae Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Sat, 24 Aug 2024 10:53:44 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20Subscriber=E3=81=ABinit=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/application/domainevent/subscribers/Subscriber.kt | 4 +++- .../application/domainevent/subscribers/SubscriberRunner.kt | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/Subscriber.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/Subscriber.kt index a538b87a..5c42bbe8 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/Subscriber.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/Subscriber.kt @@ -1,3 +1,5 @@ package dev.usbharu.hideout.core.application.domainevent.subscribers -interface Subscriber +interface Subscriber { + fun init() +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/SubscriberRunner.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/SubscriberRunner.kt index b932b8dc..1990c2f6 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/SubscriberRunner.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/SubscriberRunner.kt @@ -5,7 +5,8 @@ import org.springframework.boot.ApplicationRunner import org.springframework.stereotype.Component @Component -class SubscriberRunner(subscribers: List) : ApplicationRunner { +class SubscriberRunner(private val subscribers: List) : ApplicationRunner { override fun run(args: ApplicationArguments?) { + subscribers.forEach { it.init() } } } From e2c633a9173f881e788a544e8e878abbef2c1d87 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Sat, 24 Aug 2024 10:54:16 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20init=E9=96=A2=E6=95=B0=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E3=81=97=E3=81=A6=E5=88=9D=E6=9C=9F=E5=8C=96?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RegisterLocalUserSetHomeTimelineSubscriber.kt | 8 ++++---- .../RegisterTimelineSetTimelineStoreSubscriber.kt | 8 ++++---- .../subscribers/TimelinePostCreateSubscriber.kt | 4 ++-- .../subscribers/TimelineRelationshipFollowSubscriber.kt | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/RegisterLocalUserSetHomeTimelineSubscriber.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/RegisterLocalUserSetHomeTimelineSubscriber.kt index 48620f34..e6780dbf 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/RegisterLocalUserSetHomeTimelineSubscriber.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/RegisterLocalUserSetHomeTimelineSubscriber.kt @@ -7,11 +7,10 @@ import org.springframework.stereotype.Component @Component class RegisterLocalUserSetHomeTimelineSubscriber( - domainEventSubscriber: DomainEventSubscriber, + private val domainEventSubscriber: DomainEventSubscriber, private val userRegisterHomeTimelineApplicationService: UserRegisterHomeTimelineApplicationService -) : - Subscriber { - init { +) : Subscriber { + override fun init() { domainEventSubscriber.subscribe(UserDetailEvent.CREATE.eventName) { userRegisterHomeTimelineApplicationService.execute( RegisterHomeTimeline(it.body.getUserDetail().id), @@ -19,4 +18,5 @@ class RegisterLocalUserSetHomeTimelineSubscriber( ) } } + } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/RegisterTimelineSetTimelineStoreSubscriber.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/RegisterTimelineSetTimelineStoreSubscriber.kt index 246795c6..2b8ec1cb 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/RegisterTimelineSetTimelineStoreSubscriber.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/RegisterTimelineSetTimelineStoreSubscriber.kt @@ -9,11 +9,11 @@ import org.springframework.stereotype.Component @Component class RegisterTimelineSetTimelineStoreSubscriber( - domainEventSubscriber: DomainEventSubscriber, + private val domainEventSubscriber: DomainEventSubscriber, private val setTimelineToTimelineStoreApplicationService: SetTimelineToTimelineStoreApplicationService -) : - Subscriber { - init { +) : Subscriber { + + override fun init() { domainEventSubscriber.subscribe(TimelineEvent.CREATE.eventName) { setTimelineToTimelineStoreApplicationService.execute(SetTimleineStore(it.body.getTimelineId()), Anonymous) } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/TimelinePostCreateSubscriber.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/TimelinePostCreateSubscriber.kt index 4f407e99..663367b2 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/TimelinePostCreateSubscriber.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/TimelinePostCreateSubscriber.kt @@ -10,9 +10,9 @@ import org.springframework.stereotype.Component @Component class TimelinePostCreateSubscriber( private val timelineAddPostApplicationService: TimelineAddPostApplicationService, - domainEventSubscriber: DomainEventSubscriber, + private val domainEventSubscriber: DomainEventSubscriber, ) : Subscriber { - init { + override fun init() { domainEventSubscriber.subscribe(PostEvent.CREATE.eventName) { timelineAddPostApplicationService.execute(AddPost(it.body.getPostId()), Anonymous) } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/TimelineRelationshipFollowSubscriber.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/TimelineRelationshipFollowSubscriber.kt index 4a3e03e8..3b3970bd 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/TimelineRelationshipFollowSubscriber.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/TimelineRelationshipFollowSubscriber.kt @@ -18,10 +18,10 @@ class TimelineRelationshipFollowSubscriber( private val userAddTimelineRelationshipApplicationService: UserAddTimelineRelationshipApplicationService, private val idGenerateService: IdGenerateService, private val userDetailRepository: UserDetailRepository, - domainEventSubscriber: DomainEventSubscriber + private val domainEventSubscriber: DomainEventSubscriber ) : Subscriber { - init { + override fun init() { domainEventSubscriber.subscribe(RelationshipEvent.FOLLOW.eventName) { val relationship = it.body.getRelationship() val userDetail = userDetailRepository.findByActorId(relationship.actorId.id) From 9663cba4afafe53dba082b2baee7ac56bf7fbf81 Mon Sep 17 00:00:00 2001 From: usbharu Date: Sat, 24 Aug 2024 02:00:49 +0000 Subject: [PATCH 3/3] style: fix lint (CI) --- .../subscribers/RegisterLocalUserSetHomeTimelineSubscriber.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/RegisterLocalUserSetHomeTimelineSubscriber.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/RegisterLocalUserSetHomeTimelineSubscriber.kt index e6780dbf..a63918ee 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/RegisterLocalUserSetHomeTimelineSubscriber.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/RegisterLocalUserSetHomeTimelineSubscriber.kt @@ -18,5 +18,4 @@ class RegisterLocalUserSetHomeTimelineSubscriber( ) } } - }