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..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 @@ -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), 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/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() } } } 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)