From 22084ee4bef046f67ebfba5f8b07791bb4b4fea1 Mon Sep 17 00:00:00 2001 From: usbharu Date: Wed, 18 Sep 2024 23:31:23 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20UserFollowRequestApplicationService.kt?= =?UTF-8?q?=E3=82=92=E3=83=95=E3=82=A9=E3=83=AD=E3=83=BC=E5=89=8D=E7=8A=B6?= =?UTF-8?q?=E6=85=8B=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserFollowRequestApplicationService.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/UserFollowRequestApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/UserFollowRequestApplicationService.kt index 0e31b34b..2eee2570 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/UserFollowRequestApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/UserFollowRequestApplicationService.kt @@ -24,6 +24,7 @@ import dev.usbharu.hideout.core.domain.model.actor.ActorRepository import dev.usbharu.hideout.core.domain.model.relationship.Relationship import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository import dev.usbharu.hideout.core.domain.model.support.principal.LocalUser +import dev.usbharu.hideout.core.domain.service.relationship.RelationshipDomainService import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -32,9 +33,9 @@ class UserFollowRequestApplicationService( private val relationshipRepository: RelationshipRepository, transaction: Transaction, private val actorRepository: ActorRepository, + private val relationshipDomainService: RelationshipDomainService ) : LocalUserAbstractApplicationService( - transaction, - logger + transaction, logger ) { override suspend fun internalExecute(command: FollowRequest, principal: LocalUser) { @@ -43,11 +44,15 @@ class UserFollowRequestApplicationService( val targetId = ActorId(command.targetActorId) val relationship = relationshipRepository.findByActorIdAndTargetId(actor.id, targetId) ?: Relationship.default( - actor.id, - targetId + actor.id, targetId ) - relationship.followRequest() + val inverseRelationship = + relationshipRepository.findByActorIdAndTargetId(targetId, actor.id) ?: Relationship.default( + targetId, actor.id + ) + + relationshipDomainService.followRequest(relationship, inverseRelationship) relationshipRepository.save(relationship) }