mirror of https://github.com/usbharu/Hideout.git
feat: UserFollowRequestApplicationService.ktをフォロー前状態チェックに対応
This commit is contained in:
parent
9677b11f5c
commit
22084ee4be
|
@ -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.Relationship
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
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.model.support.principal.LocalUser
|
||||||
|
import dev.usbharu.hideout.core.domain.service.relationship.RelationshipDomainService
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -32,9 +33,9 @@ class UserFollowRequestApplicationService(
|
||||||
private val relationshipRepository: RelationshipRepository,
|
private val relationshipRepository: RelationshipRepository,
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
|
private val relationshipDomainService: RelationshipDomainService
|
||||||
) : LocalUserAbstractApplicationService<FollowRequest, Unit>(
|
) : LocalUserAbstractApplicationService<FollowRequest, Unit>(
|
||||||
transaction,
|
transaction, logger
|
||||||
logger
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override suspend fun internalExecute(command: FollowRequest, principal: LocalUser) {
|
override suspend fun internalExecute(command: FollowRequest, principal: LocalUser) {
|
||||||
|
@ -43,11 +44,15 @@ class UserFollowRequestApplicationService(
|
||||||
|
|
||||||
val targetId = ActorId(command.targetActorId)
|
val targetId = ActorId(command.targetActorId)
|
||||||
val relationship = relationshipRepository.findByActorIdAndTargetId(actor.id, targetId) ?: Relationship.default(
|
val relationship = relationshipRepository.findByActorIdAndTargetId(actor.id, targetId) ?: Relationship.default(
|
||||||
actor.id,
|
actor.id, targetId
|
||||||
targetId
|
|
||||||
)
|
)
|
||||||
|
|
||||||
relationship.followRequest()
|
val inverseRelationship =
|
||||||
|
relationshipRepository.findByActorIdAndTargetId(targetId, actor.id) ?: Relationship.default(
|
||||||
|
targetId, actor.id
|
||||||
|
)
|
||||||
|
|
||||||
|
relationshipDomainService.followRequest(relationship, inverseRelationship)
|
||||||
|
|
||||||
relationshipRepository.save(relationship)
|
relationshipRepository.save(relationship)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue