mirror of https://github.com/usbharu/Hideout.git
fix: よくない修正だったのでロールバック
This commit is contained in:
parent
94f790d039
commit
7ec997c1d5
|
@ -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<Unit, UserDetail>(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<GetUserDetail, UserDetail>(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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<IllegalArgumentException> {
|
||||
org.junit.jupiter.api.assertThrows<PermissionDeniedException> {
|
||||
value.execute(Unit, Anonymous)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<CredentialAccount> {
|
||||
val principal = principalContextHolder.getPrincipal()
|
||||
val localActor =
|
||||
getUserDetailApplicationService.execute(Unit, principal)
|
||||
getUserDetailApplicationService.execute(
|
||||
GetUserDetail(
|
||||
principal.userDetailId?.id ?: throw PermissionDeniedException()
|
||||
), principal
|
||||
)
|
||||
|
||||
return ResponseEntity.ok(
|
||||
CredentialAccount(
|
||||
|
|
Loading…
Reference in New Issue