diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/GetUserDetailApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/GetUserDetailApplicationService.kt index 0d67740d..6d990ee2 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/GetUserDetailApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/GetUserDetailApplicationService.kt @@ -17,11 +17,12 @@ package dev.usbharu.hideout.core.application.actor import dev.usbharu.hideout.core.application.exception.InternalServerException -import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService +import dev.usbharu.hideout.core.application.shared.AbstractApplicationService import dev.usbharu.hideout.core.application.shared.Transaction import dev.usbharu.hideout.core.domain.model.actor.ActorRepository import dev.usbharu.hideout.core.domain.model.emoji.CustomEmojiRepository -import dev.usbharu.hideout.core.domain.model.support.principal.FromApi +import dev.usbharu.hideout.core.domain.model.support.principal.Principal +import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -33,10 +34,10 @@ class GetUserDetailApplicationService( private val customEmojiRepository: CustomEmojiRepository, transaction: Transaction, ) : - LocalUserAbstractApplicationService(transaction, Companion.logger) { - override suspend fun internalExecute(command: Unit, principal: FromApi): UserDetail { - val userDetail = userDetailRepository.findById(principal.userDetailId) - ?: throw IllegalArgumentException("User ${principal.userDetailId} does not exist") + AbstractApplicationService(transaction, Companion.logger) { + override suspend fun internalExecute(command: GetUserDetail, principal: Principal): UserDetail { + val userDetail = userDetailRepository.findById(UserDetailId(command.id)) + ?: throw IllegalArgumentException("User ${command.id} does not exist") val actor = actorRepository.findById(userDetail.actorId) ?: throw InternalServerException("Actor ${userDetail.actorId} not found") @@ -46,6 +47,6 @@ class GetUserDetailApplicationService( } companion object { - private val logger = LoggerFactory.getLogger(GetUserDetailApplicationService::class.java) + val logger = LoggerFactory.getLogger(GetUserDetailApplicationService::class.java) } } diff --git a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/application/shared/LocalUserAbstractApplicationServiceTest.kt b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/application/shared/LocalUserAbstractApplicationServiceTest.kt index a52a29d7..581bac6a 100644 --- a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/application/shared/LocalUserAbstractApplicationServiceTest.kt +++ b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/application/shared/LocalUserAbstractApplicationServiceTest.kt @@ -1,5 +1,6 @@ package dev.usbharu.hideout.core.application.shared +import dev.usbharu.hideout.core.application.exception.PermissionDeniedException import dev.usbharu.hideout.core.domain.model.support.principal.Anonymous import dev.usbharu.hideout.core.domain.model.support.principal.FromApi import kotlinx.coroutines.test.runTest @@ -17,7 +18,7 @@ class LocalUserAbstractApplicationServiceTest { } } - org.junit.jupiter.api.assertThrows { + org.junit.jupiter.api.assertThrows { value.execute(Unit, Anonymous) } } diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringAccountApi.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringAccountApi.kt index a860cded..15b9226b 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringAccountApi.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringAccountApi.kt @@ -16,7 +16,9 @@ package dev.usbharu.hideout.mastodon.interfaces.api +import dev.usbharu.hideout.core.application.actor.GetUserDetail import dev.usbharu.hideout.core.application.actor.GetUserDetailApplicationService +import dev.usbharu.hideout.core.application.exception.PermissionDeniedException import dev.usbharu.hideout.core.application.relationship.acceptfollowrequest.AcceptFollowRequest import dev.usbharu.hideout.core.application.relationship.acceptfollowrequest.UserAcceptFollowRequestApplicationService import dev.usbharu.hideout.core.application.relationship.block.Block @@ -159,7 +161,11 @@ class SpringAccountApi( override suspend fun apiV1AccountsVerifyCredentialsGet(): ResponseEntity { val principal = principalContextHolder.getPrincipal() val localActor = - getUserDetailApplicationService.execute(Unit, principal) + getUserDetailApplicationService.execute( + GetUserDetail( + principal.userDetailId?.id ?: throw PermissionDeniedException() + ), principal + ) return ResponseEntity.ok( CredentialAccount(