mirror of https://github.com/usbharu/Hideout.git
refactor: principalのactorIdを使用するように
This commit is contained in:
parent
e082b0b7b9
commit
507c1d8932
|
@ -23,7 +23,6 @@ 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.FromApi
|
import dev.usbharu.hideout.core.domain.model.support.principal.FromApi
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
|
||||||
import dev.usbharu.hideout.core.domain.service.relationship.RelationshipDomainService
|
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
|
||||||
|
@ -33,14 +32,14 @@ class UserBlockApplicationService(
|
||||||
private val relationshipRepository: RelationshipRepository,
|
private val relationshipRepository: RelationshipRepository,
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
private val userDetailRepository: UserDetailRepository,
|
|
||||||
private val relationshipDomainService: RelationshipDomainService,
|
private val relationshipDomainService: RelationshipDomainService,
|
||||||
) :
|
) :
|
||||||
LocalUserAbstractApplicationService<Block, Unit>(transaction, logger) {
|
LocalUserAbstractApplicationService<Block, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: Block, principal: FromApi) {
|
override suspend fun internalExecute(command: Block, principal: FromApi) {
|
||||||
|
|
||||||
val userDetail = userDetailRepository.findById(principal.userDetailId)!!
|
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(principal.actorId)
|
||||||
|
?: throw IllegalStateException("Actor ${principal.actorId} not found")
|
||||||
|
|
||||||
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(
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.followrequest
|
package dev.usbharu.hideout.core.application.relationship.followrequest
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.application.exception.InternalServerException
|
||||||
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
|
@ -23,7 +24,6 @@ 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.FromApi
|
import dev.usbharu.hideout.core.domain.model.support.principal.FromApi
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -32,16 +32,14 @@ class UserFollowRequestApplicationService(
|
||||||
private val relationshipRepository: RelationshipRepository,
|
private val relationshipRepository: RelationshipRepository,
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
private val userDetailRepository: UserDetailRepository,
|
|
||||||
) : LocalUserAbstractApplicationService<FollowRequest, Unit>(
|
) : LocalUserAbstractApplicationService<FollowRequest, Unit>(
|
||||||
transaction,
|
transaction,
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override suspend fun internalExecute(command: FollowRequest, principal: FromApi) {
|
override suspend fun internalExecute(command: FollowRequest, principal: FromApi) {
|
||||||
|
val actor = actorRepository.findById(principal.actorId)
|
||||||
val userDetail = userDetailRepository.findById(principal.userDetailId)!!
|
?: throw InternalServerException("Actor ${principal.actorId} not found.")
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
|
||||||
|
|
||||||
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(
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.get
|
package dev.usbharu.hideout.core.application.relationship.get
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.application.exception.InternalServerException
|
||||||
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
|
@ -24,7 +25,6 @@ import dev.usbharu.hideout.core.domain.model.actorinstancerelationship.ActorInst
|
||||||
import dev.usbharu.hideout.core.domain.model.actorinstancerelationship.ActorInstanceRelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.actorinstancerelationship.ActorInstanceRelationshipRepository
|
||||||
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.FromApi
|
import dev.usbharu.hideout.core.domain.model.support.principal.FromApi
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ import org.springframework.stereotype.Service
|
||||||
class GetRelationshipApplicationService(
|
class GetRelationshipApplicationService(
|
||||||
private val relationshipRepository: RelationshipRepository,
|
private val relationshipRepository: RelationshipRepository,
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
private val userDetailRepository: UserDetailRepository,
|
|
||||||
private val actorInstanceRelationshipRepository: ActorInstanceRelationshipRepository,
|
private val actorInstanceRelationshipRepository: ActorInstanceRelationshipRepository,
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
) :
|
) :
|
||||||
|
@ -41,19 +40,20 @@ class GetRelationshipApplicationService(
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
override suspend fun internalExecute(command: GetRelationship, principal: FromApi): Relationship {
|
override suspend fun internalExecute(command: GetRelationship, principal: FromApi): Relationship {
|
||||||
val userDetail = userDetailRepository.findById(principal.userDetailId)!!
|
val actor = actorRepository.findById(principal.actorId)
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
?: throw InternalServerException("Actor ${principal.actorId} not found.")
|
||||||
val targetId = ActorId(command.targetActorId)
|
val targetId = ActorId(command.targetActorId)
|
||||||
val target = actorRepository.findById(targetId)!!
|
val target = actorRepository.findById(targetId)
|
||||||
|
?: throw IllegalArgumentException("Actor ${command.targetActorId} not found.")
|
||||||
val relationship = (
|
val relationship = (
|
||||||
relationshipRepository.findByActorIdAndTargetId(actor.id, targetId)
|
relationshipRepository.findByActorIdAndTargetId(actor.id, targetId)
|
||||||
?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(actor.id, targetId)
|
?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(actor.id, targetId)
|
||||||
)
|
)
|
||||||
|
|
||||||
val relationship1 = (
|
val relationship1 = (
|
||||||
relationshipRepository.findByActorIdAndTargetId(targetId, actor.id)
|
relationshipRepository.findByActorIdAndTargetId(targetId, actor.id)
|
||||||
?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(targetId, actor.id)
|
?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(targetId, actor.id)
|
||||||
)
|
)
|
||||||
|
|
||||||
val actorInstanceRelationship =
|
val actorInstanceRelationship =
|
||||||
actorInstanceRelationshipRepository.findByActorIdAndInstanceId(actor.id, target.instance)
|
actorInstanceRelationshipRepository.findByActorIdAndInstanceId(actor.id, target.instance)
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.mute
|
package dev.usbharu.hideout.core.application.relationship.mute
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.application.exception.InternalServerException
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
|
@ -24,7 +25,6 @@ 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.FromApi
|
import dev.usbharu.hideout.core.domain.model.support.principal.FromApi
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -33,13 +33,11 @@ class UserMuteApplicationService(
|
||||||
private val relationshipRepository: RelationshipRepository,
|
private val relationshipRepository: RelationshipRepository,
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
private val userDetailRepository: UserDetailRepository,
|
|
||||||
) :
|
) :
|
||||||
LocalUserAbstractApplicationService<Mute, Unit>(transaction, logger) {
|
LocalUserAbstractApplicationService<Mute, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: Mute, principal: FromApi) {
|
override suspend fun internalExecute(command: Mute, principal: FromApi) {
|
||||||
|
val actor = actorRepository.findById(principal.actorId)
|
||||||
val userDetail = userDetailRepository.findById(principal.userDetailId)!!
|
?: throw InternalServerException("Actor ${principal.actorId} not found.")
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
|
||||||
|
|
||||||
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(
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.rejectfollowrequest
|
package dev.usbharu.hideout.core.application.relationship.rejectfollowrequest
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.application.exception.InternalServerException
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
|
@ -23,7 +24,6 @@ import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
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.FromApi
|
import dev.usbharu.hideout.core.domain.model.support.principal.FromApi
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -32,13 +32,11 @@ class UserRejectFollowRequestApplicationService(
|
||||||
private val relationshipRepository: RelationshipRepository,
|
private val relationshipRepository: RelationshipRepository,
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
private val userDetailRepository: UserDetailRepository,
|
|
||||||
) :
|
) :
|
||||||
LocalUserAbstractApplicationService<RejectFollowRequest, Unit>(transaction, logger) {
|
LocalUserAbstractApplicationService<RejectFollowRequest, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: RejectFollowRequest, principal: FromApi) {
|
override suspend fun internalExecute(command: RejectFollowRequest, principal: FromApi) {
|
||||||
|
val actor = actorRepository.findById(principal.actorId)
|
||||||
val userDetail = userDetailRepository.findById(principal.userDetailId)!!
|
?: throw InternalServerException("Actor ${principal.actorId} not found.")
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
|
||||||
|
|
||||||
val targetId = ActorId(command.sourceActorId)
|
val targetId = ActorId(command.sourceActorId)
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.removefromfollowers
|
package dev.usbharu.hideout.core.application.relationship.removefromfollowers
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.application.exception.InternalServerException
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
|
@ -24,7 +25,6 @@ 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.FromApi
|
import dev.usbharu.hideout.core.domain.model.support.principal.FromApi
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -33,13 +33,11 @@ class UserRemoveFromFollowersApplicationService(
|
||||||
private val relationshipRepository: RelationshipRepository,
|
private val relationshipRepository: RelationshipRepository,
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
private val userDetailRepository: UserDetailRepository,
|
|
||||||
) :
|
) :
|
||||||
LocalUserAbstractApplicationService<RemoveFromFollowers, Unit>(transaction, logger) {
|
LocalUserAbstractApplicationService<RemoveFromFollowers, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: RemoveFromFollowers, principal: FromApi) {
|
override suspend fun internalExecute(command: RemoveFromFollowers, principal: FromApi) {
|
||||||
|
val actor = actorRepository.findById(principal.actorId)
|
||||||
val userDetail = userDetailRepository.findById(principal.userDetailId)!!
|
?: throw InternalServerException("Actor ${principal.actorId} not found.")
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
|
||||||
|
|
||||||
val targetId = ActorId(command.targetActorId)
|
val targetId = ActorId(command.targetActorId)
|
||||||
val relationship = relationshipRepository.findByActorIdAndTargetId(targetId, actor.id) ?: Relationship.default(
|
val relationship = relationshipRepository.findByActorIdAndTargetId(targetId, actor.id) ?: Relationship.default(
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.unblock
|
package dev.usbharu.hideout.core.application.relationship.unblock
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.application.exception.InternalServerException
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
|
@ -24,7 +25,6 @@ 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.FromApi
|
import dev.usbharu.hideout.core.domain.model.support.principal.FromApi
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -33,13 +33,11 @@ class UserUnblockApplicationService(
|
||||||
private val relationshipRepository: RelationshipRepository,
|
private val relationshipRepository: RelationshipRepository,
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
private val userDetailRepository: UserDetailRepository,
|
|
||||||
) :
|
) :
|
||||||
LocalUserAbstractApplicationService<Unblock, Unit>(transaction, logger) {
|
LocalUserAbstractApplicationService<Unblock, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: Unblock, principal: FromApi) {
|
override suspend fun internalExecute(command: Unblock, principal: FromApi) {
|
||||||
|
val actor = actorRepository.findById(principal.actorId)
|
||||||
val userDetail = userDetailRepository.findById(principal.userDetailId)!!
|
?: throw InternalServerException("Actor ${principal.actorId} not found.")
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
|
||||||
|
|
||||||
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(
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.unfollow
|
package dev.usbharu.hideout.core.application.relationship.unfollow
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.application.exception.InternalServerException
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
|
@ -24,7 +25,6 @@ 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.FromApi
|
import dev.usbharu.hideout.core.domain.model.support.principal.FromApi
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -33,13 +33,11 @@ class UserUnfollowApplicationService(
|
||||||
private val relationshipRepository: RelationshipRepository,
|
private val relationshipRepository: RelationshipRepository,
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
private val userDetailRepository: UserDetailRepository,
|
|
||||||
) :
|
) :
|
||||||
LocalUserAbstractApplicationService<Unfollow, Unit>(transaction, logger) {
|
LocalUserAbstractApplicationService<Unfollow, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: Unfollow, principal: FromApi) {
|
override suspend fun internalExecute(command: Unfollow, principal: FromApi) {
|
||||||
|
val actor = actorRepository.findById(principal.actorId)
|
||||||
val userDetail = userDetailRepository.findById(principal.userDetailId)!!
|
?: throw InternalServerException("Actor ${principal.actorId} not found.")
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
|
||||||
|
|
||||||
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(
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.unmute
|
package dev.usbharu.hideout.core.application.relationship.unmute
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.application.exception.InternalServerException
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
|
@ -24,7 +25,6 @@ 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.FromApi
|
import dev.usbharu.hideout.core.domain.model.support.principal.FromApi
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ class UserUnmuteApplicationService(
|
||||||
private val relationshipRepository: RelationshipRepository,
|
private val relationshipRepository: RelationshipRepository,
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
private val userDetailRepository: UserDetailRepository,
|
|
||||||
) :
|
) :
|
||||||
LocalUserAbstractApplicationService<Unmute, Unit>(transaction, logger) {
|
LocalUserAbstractApplicationService<Unmute, Unit>(transaction, logger) {
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -41,9 +40,8 @@ class UserUnmuteApplicationService(
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun internalExecute(command: Unmute, principal: FromApi) {
|
override suspend fun internalExecute(command: Unmute, principal: FromApi) {
|
||||||
|
val actor = actorRepository.findById(principal.actorId)
|
||||||
val userDetail = userDetailRepository.findById(principal.userDetailId)!!
|
?: throw InternalServerException("Actor ${principal.actorId} not found.")
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
|
||||||
|
|
||||||
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(
|
||||||
|
|
Loading…
Reference in New Issue