mirror of https://github.com/usbharu/Hideout.git
fix: トランザクションの修正
This commit is contained in:
parent
0d5fecbd4d
commit
51aeff6015
|
@ -14,6 +14,7 @@ import dev.usbharu.hideout.core.query.UserQueryService
|
||||||
import dev.usbharu.hideout.core.service.user.RemoteUserCreateDto
|
import dev.usbharu.hideout.core.service.user.RemoteUserCreateDto
|
||||||
import dev.usbharu.hideout.core.service.user.UserService
|
import dev.usbharu.hideout.core.service.user.UserService
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
import org.springframework.transaction.annotation.Transactional
|
||||||
|
|
||||||
interface APUserService {
|
interface APUserService {
|
||||||
suspend fun getPersonByName(name: String): Person
|
suspend fun getPersonByName(name: String): Person
|
||||||
|
@ -74,6 +75,7 @@ class APUserServiceImpl(
|
||||||
override suspend fun fetchPerson(url: String, targetActor: String?): Person =
|
override suspend fun fetchPerson(url: String, targetActor: String?): Person =
|
||||||
fetchPersonWithEntity(url, targetActor).first
|
fetchPersonWithEntity(url, targetActor).first
|
||||||
|
|
||||||
|
@Transactional
|
||||||
override suspend fun fetchPersonWithEntity(url: String, targetActor: String?): Pair<Person, User> {
|
override suspend fun fetchPersonWithEntity(url: String, targetActor: String?): Pair<Person, User> {
|
||||||
return try {
|
return try {
|
||||||
val userEntity = userQueryService.findByUrl(url)
|
val userEntity = userQueryService.findByUrl(url)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import dev.usbharu.hideout.core.service.instance.InstanceService
|
||||||
import org.jetbrains.exposed.exceptions.ExposedSQLException
|
import org.jetbrains.exposed.exceptions.ExposedSQLException
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
import org.springframework.transaction.annotation.Transactional
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -57,6 +58,7 @@ class UserServiceImpl(
|
||||||
return userRepository.save(userEntity)
|
return userRepository.save(userEntity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
override suspend fun createRemoteUser(user: RemoteUserCreateDto): User {
|
override suspend fun createRemoteUser(user: RemoteUserCreateDto): User {
|
||||||
@Suppress("TooGenericExceptionCaught")
|
@Suppress("TooGenericExceptionCaught")
|
||||||
val instance = try {
|
val instance = try {
|
||||||
|
|
|
@ -55,8 +55,7 @@ class UserAPControllerImplTest {
|
||||||
publicKey = Key(
|
publicKey = Key(
|
||||||
id = "https://example.com/users/hoge#pubkey",
|
id = "https://example.com/users/hoge#pubkey",
|
||||||
owner = "https://example.com/users/hoge",
|
owner = "https://example.com/users/hoge",
|
||||||
publicKeyPem = "-----BEGIN PUBLIC KEY-----...-----END PUBLIC KEY-----",
|
publicKeyPem = "-----BEGIN PUBLIC KEY-----...-----END PUBLIC KEY-----"
|
||||||
type = emptyList()
|
|
||||||
),
|
),
|
||||||
endpoints = mapOf("sharedInbox" to "https://example.com/inbox"),
|
endpoints = mapOf("sharedInbox" to "https://example.com/inbox"),
|
||||||
followers = "https://example.com/users/hoge/followers",
|
followers = "https://example.com/users/hoge/followers",
|
||||||
|
|
Loading…
Reference in New Issue