mirror of https://github.com/usbharu/Hideout.git
refactor: actorのDBからの取得に関する大規模な変更
This commit is contained in:
parent
382fe89142
commit
f98178b37c
|
@ -1,7 +1,7 @@
|
||||||
package mastodon.account
|
package mastodon.account
|
||||||
|
|
||||||
import dev.usbharu.hideout.SpringApplication
|
import dev.usbharu.hideout.SpringApplication
|
||||||
import dev.usbharu.hideout.core.infrastructure.exposedquery.ActorQueryServiceImpl
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.infrastructure.exposedquery.FollowerQueryServiceImpl
|
import dev.usbharu.hideout.core.infrastructure.exposedquery.FollowerQueryServiceImpl
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
|
@ -39,7 +39,7 @@ class AccountApiTest {
|
||||||
private lateinit var followerQueryServiceImpl: FollowerQueryServiceImpl
|
private lateinit var followerQueryServiceImpl: FollowerQueryServiceImpl
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private lateinit var userQueryServiceImpl: ActorQueryServiceImpl
|
private lateinit var actorRepository: ActorRepository
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -100,7 +100,7 @@ class AccountApiTest {
|
||||||
.asyncDispatch()
|
.asyncDispatch()
|
||||||
.andExpect { status { isFound() } }
|
.andExpect { status { isFound() } }
|
||||||
|
|
||||||
userQueryServiceImpl.findByNameAndDomain("api-test-user-1", "example.com")
|
actorRepository.findByNameAndDomain("api-test-user-1", "example.com")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -116,7 +116,7 @@ class AccountApiTest {
|
||||||
.asyncDispatch()
|
.asyncDispatch()
|
||||||
.andExpect { status { isFound() } }
|
.andExpect { status { isFound() } }
|
||||||
|
|
||||||
userQueryServiceImpl.findByNameAndDomain("api-test-user-2", "example.com")
|
actorRepository.findByNameAndDomain("api-test-user-2", "example.com")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package util
|
package util
|
||||||
|
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.infrastructure.springframework.httpsignature.HttpSignatureUser
|
import dev.usbharu.hideout.core.infrastructure.springframework.httpsignature.HttpSignatureUser
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.httpsignature.common.HttpHeaders
|
import dev.usbharu.httpsignature.common.HttpHeaders
|
||||||
import dev.usbharu.httpsignature.common.HttpMethod
|
import dev.usbharu.httpsignature.common.HttpMethod
|
||||||
import dev.usbharu.httpsignature.common.HttpRequest
|
import dev.usbharu.httpsignature.common.HttpRequest
|
||||||
|
@ -14,7 +15,7 @@ import org.springframework.security.web.authentication.preauth.PreAuthenticatedA
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
|
||||||
class WithHttpSignatureSecurityContextFactory(
|
class WithHttpSignatureSecurityContextFactory(
|
||||||
private val actorQueryService: ActorQueryService,
|
private val actorRepository: ActorRepository,
|
||||||
private val transaction: Transaction
|
private val transaction: Transaction
|
||||||
) : WithSecurityContextFactory<WithHttpSignature> {
|
) : WithSecurityContextFactory<WithHttpSignature> {
|
||||||
|
|
||||||
|
@ -28,7 +29,8 @@ class WithHttpSignatureSecurityContextFactory(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val httpSignatureUser = transaction.transaction {
|
val httpSignatureUser = transaction.transaction {
|
||||||
val findByKeyId = actorQueryService.findByKeyId(annotation.keyId)
|
val findByKeyId =
|
||||||
|
actorRepository.findByKeyId(annotation.keyId) ?: throw UserNotFoundException.withKeyId(annotation.keyId)
|
||||||
HttpSignatureUser(
|
HttpSignatureUser(
|
||||||
findByKeyId.name,
|
findByKeyId.name,
|
||||||
findByKeyId.domain,
|
findByKeyId.domain,
|
||||||
|
|
|
@ -2,22 +2,22 @@ package dev.usbharu.hideout.activitypub.service.activity.accept
|
||||||
|
|
||||||
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverAcceptJob
|
import dev.usbharu.hideout.core.external.job.DeliverAcceptJob
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverAcceptJobParam
|
import dev.usbharu.hideout.core.external.job.DeliverAcceptJobParam
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.service.job.JobProcessor
|
import dev.usbharu.hideout.core.service.job.JobProcessor
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class APDeliverAcceptJobProcessor(
|
class APDeliverAcceptJobProcessor(
|
||||||
private val apRequestService: APRequestService,
|
private val apRequestService: APRequestService,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val deliverAcceptJob: DeliverAcceptJob,
|
private val deliverAcceptJob: DeliverAcceptJob,
|
||||||
private val transaction: Transaction
|
private val transaction: Transaction,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) :
|
) :
|
||||||
JobProcessor<DeliverAcceptJobParam, DeliverAcceptJob> {
|
JobProcessor<DeliverAcceptJobParam, DeliverAcceptJob> {
|
||||||
override suspend fun process(param: DeliverAcceptJobParam): Unit = transaction.transaction {
|
override suspend fun process(param: DeliverAcceptJobParam): Unit = transaction.transaction {
|
||||||
apRequestService.apPost(param.inbox, param.accept, actorQueryService.findById(param.signer))
|
apRequestService.apPost(param.inbox, param.accept, actorRepository.findById(param.signer))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun job(): DeliverAcceptJob = deliverAcceptJob
|
override fun job(): DeliverAcceptJob = deliverAcceptJob
|
||||||
|
|
|
@ -7,15 +7,16 @@ import dev.usbharu.hideout.activitypub.service.common.AbstractActivityPubProcess
|
||||||
import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext
|
import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext
|
||||||
import dev.usbharu.hideout.activitypub.service.common.ActivityType
|
import dev.usbharu.hideout.activitypub.service.common.ActivityType
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class ApAcceptProcessor(
|
class ApAcceptProcessor(
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val actorQueryService: ActorQueryService,
|
private val relationshipService: RelationshipService,
|
||||||
private val relationshipService: RelationshipService
|
private val actorRepository: ActorRepository
|
||||||
) :
|
) :
|
||||||
AbstractActivityPubProcessor<Accept>(transaction) {
|
AbstractActivityPubProcessor<Accept>(transaction) {
|
||||||
|
|
||||||
|
@ -32,8 +33,8 @@ class ApAcceptProcessor(
|
||||||
val userUrl = follow.apObject
|
val userUrl = follow.apObject
|
||||||
val followerUrl = follow.actor
|
val followerUrl = follow.actor
|
||||||
|
|
||||||
val user = actorQueryService.findByUrl(userUrl)
|
val user = actorRepository.findByUrl(userUrl) ?: throw UserNotFoundException.withUrl(userUrl)
|
||||||
val follower = actorQueryService.findByUrl(followerUrl)
|
val follower = actorRepository.findByUrl(followerUrl) ?: throw UserNotFoundException.withUrl(followerUrl)
|
||||||
|
|
||||||
relationshipService.acceptFollowRequest(user.id, follower.id)
|
relationshipService.acceptFollowRequest(user.id, follower.id)
|
||||||
logger.debug("SUCCESS Follow from ${user.url} to ${follower.url}.")
|
logger.debug("SUCCESS Follow from ${user.url} to ${follower.url}.")
|
||||||
|
|
|
@ -5,7 +5,8 @@ import dev.usbharu.hideout.activitypub.service.common.AbstractActivityPubProcess
|
||||||
import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext
|
import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext
|
||||||
import dev.usbharu.hideout.activitypub.service.common.ActivityType
|
import dev.usbharu.hideout.activitypub.service.common.ActivityType
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -14,14 +15,17 @@ import org.springframework.stereotype.Service
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
class BlockActivityPubProcessor(
|
class BlockActivityPubProcessor(
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val relationshipService: RelationshipService,
|
private val relationshipService: RelationshipService,
|
||||||
|
private val actorRepository: ActorRepository,
|
||||||
transaction: Transaction
|
transaction: Transaction
|
||||||
) :
|
) :
|
||||||
AbstractActivityPubProcessor<Block>(transaction) {
|
AbstractActivityPubProcessor<Block>(transaction) {
|
||||||
override suspend fun internalProcess(activity: ActivityPubProcessContext<Block>) {
|
override suspend fun internalProcess(activity: ActivityPubProcessContext<Block>) {
|
||||||
val user = actorQueryService.findByUrl(activity.activity.actor)
|
val user = actorRepository.findByUrl(activity.activity.actor)
|
||||||
val target = actorQueryService.findByUrl(activity.activity.apObject)
|
?: throw UserNotFoundException.withUrl(activity.activity.actor)
|
||||||
|
val target = actorRepository.findByUrl(activity.activity.apObject) ?: throw UserNotFoundException.withUrl(
|
||||||
|
activity.activity.apObject
|
||||||
|
)
|
||||||
relationshipService.block(user.id, target.id)
|
relationshipService.block(user.id, target.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,10 @@ import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
import dev.usbharu.hideout.activitypub.domain.model.Create
|
import dev.usbharu.hideout.activitypub.domain.model.Create
|
||||||
import dev.usbharu.hideout.activitypub.query.NoteQueryService
|
import dev.usbharu.hideout.activitypub.query.NoteQueryService
|
||||||
import dev.usbharu.hideout.application.config.ApplicationConfig
|
import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.post.Post
|
import dev.usbharu.hideout.core.domain.model.post.Post
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverPostJob
|
import dev.usbharu.hideout.core.external.job.DeliverPostJob
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.query.FollowerQueryService
|
import dev.usbharu.hideout.core.query.FollowerQueryService
|
||||||
import dev.usbharu.hideout.core.service.job.JobQueueParentService
|
import dev.usbharu.hideout.core.service.job.JobQueueParentService
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
@ -17,9 +18,9 @@ class ApSendCreateServiceImpl(
|
||||||
private val followerQueryService: FollowerQueryService,
|
private val followerQueryService: FollowerQueryService,
|
||||||
private val objectMapper: ObjectMapper,
|
private val objectMapper: ObjectMapper,
|
||||||
private val jobQueueParentService: JobQueueParentService,
|
private val jobQueueParentService: JobQueueParentService,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val noteQueryService: NoteQueryService,
|
private val noteQueryService: NoteQueryService,
|
||||||
private val applicationConfig: ApplicationConfig
|
private val applicationConfig: ApplicationConfig,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) : ApSendCreateService {
|
) : ApSendCreateService {
|
||||||
override suspend fun createNote(post: Post) {
|
override suspend fun createNote(post: Post) {
|
||||||
logger.info("CREATE Create Local Note ${post.url}")
|
logger.info("CREATE Create Local Note ${post.url}")
|
||||||
|
@ -29,7 +30,7 @@ class ApSendCreateServiceImpl(
|
||||||
|
|
||||||
logger.debug("DELIVER Deliver Note Create ${followers.size} accounts.")
|
logger.debug("DELIVER Deliver Note Create ${followers.size} accounts.")
|
||||||
|
|
||||||
val userEntity = actorQueryService.findById(post.actorId)
|
val userEntity = actorRepository.findById(post.actorId) ?: throw UserNotFoundException.withId(post.actorId)
|
||||||
val note = noteQueryService.findById(post.id).first
|
val note = noteQueryService.findById(post.id).first
|
||||||
val create = Create(
|
val create = Create(
|
||||||
name = "Create Note",
|
name = "Create Note",
|
||||||
|
|
|
@ -9,7 +9,7 @@ import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext
|
||||||
import dev.usbharu.hideout.activitypub.service.common.ActivityType
|
import dev.usbharu.hideout.activitypub.service.common.ActivityType
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.query.PostQueryService
|
import dev.usbharu.hideout.core.query.PostQueryService
|
||||||
import dev.usbharu.hideout.core.service.post.PostService
|
import dev.usbharu.hideout.core.service.post.PostService
|
||||||
import dev.usbharu.hideout.core.service.user.UserService
|
import dev.usbharu.hideout.core.service.user.UserService
|
||||||
|
@ -19,9 +19,9 @@ import org.springframework.stereotype.Service
|
||||||
class APDeleteProcessor(
|
class APDeleteProcessor(
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val postQueryService: PostQueryService,
|
private val postQueryService: PostQueryService,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val userService: UserService,
|
private val userService: UserService,
|
||||||
private val postService: PostService
|
private val postService: PostService,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) :
|
) :
|
||||||
AbstractActivityPubProcessor<Delete>(transaction) {
|
AbstractActivityPubProcessor<Delete>(transaction) {
|
||||||
override suspend fun internalProcess(activity: ActivityPubProcessContext<Delete>) {
|
override suspend fun internalProcess(activity: ActivityPubProcessContext<Delete>) {
|
||||||
|
@ -34,12 +34,9 @@ class APDeleteProcessor(
|
||||||
throw IllegalActivityPubObjectException("object hasn't id or object")
|
throw IllegalActivityPubObjectException("object hasn't id or object")
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
val actor = actorRepository.findByUrl(deleteId)
|
||||||
val actor = actorQueryService.findByUrl(deleteId)
|
actor?.let { userService.deleteRemoteActor(it.id) }
|
||||||
userService.deleteRemoteActor(actor.id)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
logger.warn("FAILED delete id: {} is not found.", deleteId, e)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val post = postQueryService.findByApId(deleteId)
|
val post = postQueryService.findByApId(deleteId)
|
||||||
|
|
|
@ -2,21 +2,21 @@ package dev.usbharu.hideout.activitypub.service.activity.delete
|
||||||
|
|
||||||
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverDeleteJob
|
import dev.usbharu.hideout.core.external.job.DeliverDeleteJob
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverDeleteJobParam
|
import dev.usbharu.hideout.core.external.job.DeliverDeleteJobParam
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.service.job.JobProcessor
|
import dev.usbharu.hideout.core.service.job.JobProcessor
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class APDeliverDeleteJobProcessor(
|
class APDeliverDeleteJobProcessor(
|
||||||
private val apRequestService: APRequestService,
|
private val apRequestService: APRequestService,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val transaction: Transaction,
|
private val transaction: Transaction,
|
||||||
private val deliverDeleteJob: DeliverDeleteJob
|
private val deliverDeleteJob: DeliverDeleteJob,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) : JobProcessor<DeliverDeleteJobParam, DeliverDeleteJob> {
|
) : JobProcessor<DeliverDeleteJobParam, DeliverDeleteJob> {
|
||||||
override suspend fun process(param: DeliverDeleteJobParam): Unit = transaction.transaction {
|
override suspend fun process(param: DeliverDeleteJobParam): Unit = transaction.transaction {
|
||||||
apRequestService.apPost(param.inbox, param.delete, actorQueryService.findById(param.signer))
|
apRequestService.apPost(param.inbox, param.delete, actorRepository.findById(param.signer))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun job(): DeliverDeleteJob = deliverDeleteJob
|
override fun job(): DeliverDeleteJob = deliverDeleteJob
|
||||||
|
|
|
@ -4,11 +4,12 @@ import dev.usbharu.hideout.activitypub.domain.model.Delete
|
||||||
import dev.usbharu.hideout.activitypub.domain.model.Tombstone
|
import dev.usbharu.hideout.activitypub.domain.model.Tombstone
|
||||||
import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectValue
|
import dev.usbharu.hideout.activitypub.domain.model.objects.ObjectValue
|
||||||
import dev.usbharu.hideout.application.config.ApplicationConfig
|
import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.post.Post
|
import dev.usbharu.hideout.core.domain.model.post.Post
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverDeleteJob
|
import dev.usbharu.hideout.core.external.job.DeliverDeleteJob
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverDeleteJobParam
|
import dev.usbharu.hideout.core.external.job.DeliverDeleteJobParam
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.query.FollowerQueryService
|
import dev.usbharu.hideout.core.query.FollowerQueryService
|
||||||
import dev.usbharu.hideout.core.service.job.JobQueueParentService
|
import dev.usbharu.hideout.core.service.job.JobQueueParentService
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -24,11 +25,12 @@ class APSendDeleteServiceImpl(
|
||||||
private val jobQueueParentService: JobQueueParentService,
|
private val jobQueueParentService: JobQueueParentService,
|
||||||
private val delverDeleteJob: DeliverDeleteJob,
|
private val delverDeleteJob: DeliverDeleteJob,
|
||||||
private val followerQueryService: FollowerQueryService,
|
private val followerQueryService: FollowerQueryService,
|
||||||
private val actorQueryService: ActorQueryService,
|
private val applicationConfig: ApplicationConfig,
|
||||||
private val applicationConfig: ApplicationConfig
|
private val actorRepository: ActorRepository
|
||||||
) : APSendDeleteService {
|
) : APSendDeleteService {
|
||||||
override suspend fun sendDeleteNote(deletedPost: Post) {
|
override suspend fun sendDeleteNote(deletedPost: Post) {
|
||||||
val actor = actorQueryService.findById(deletedPost.actorId)
|
val actor =
|
||||||
|
actorRepository.findById(deletedPost.actorId) ?: throw UserNotFoundException.withId(deletedPost.actorId)
|
||||||
val followersById = followerQueryService.findFollowersById(deletedPost.actorId)
|
val followersById = followerQueryService.findFollowersById(deletedPost.actorId)
|
||||||
|
|
||||||
val delete = Delete(
|
val delete = Delete(
|
||||||
|
|
|
@ -5,9 +5,10 @@ import com.fasterxml.jackson.module.kotlin.readValue
|
||||||
import dev.usbharu.hideout.activitypub.domain.model.Follow
|
import dev.usbharu.hideout.activitypub.domain.model.Follow
|
||||||
import dev.usbharu.hideout.activitypub.service.objects.user.APUserService
|
import dev.usbharu.hideout.activitypub.service.objects.user.APUserService
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.external.job.ReceiveFollowJob
|
import dev.usbharu.hideout.core.external.job.ReceiveFollowJob
|
||||||
import dev.usbharu.hideout.core.external.job.ReceiveFollowJobParam
|
import dev.usbharu.hideout.core.external.job.ReceiveFollowJobParam
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.service.job.JobProcessor
|
import dev.usbharu.hideout.core.service.job.JobProcessor
|
||||||
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
@ -16,10 +17,10 @@ import org.springframework.stereotype.Service
|
||||||
@Service
|
@Service
|
||||||
class APReceiveFollowJobProcessor(
|
class APReceiveFollowJobProcessor(
|
||||||
private val transaction: Transaction,
|
private val transaction: Transaction,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val apUserService: APUserService,
|
private val apUserService: APUserService,
|
||||||
private val objectMapper: ObjectMapper,
|
private val objectMapper: ObjectMapper,
|
||||||
private val relationshipService: RelationshipService
|
private val relationshipService: RelationshipService,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) :
|
) :
|
||||||
JobProcessor<ReceiveFollowJobParam, ReceiveFollowJob> {
|
JobProcessor<ReceiveFollowJobParam, ReceiveFollowJob> {
|
||||||
override suspend fun process(param: ReceiveFollowJobParam) = transaction.transaction {
|
override suspend fun process(param: ReceiveFollowJobParam) = transaction.transaction {
|
||||||
|
@ -28,9 +29,10 @@ class APReceiveFollowJobProcessor(
|
||||||
|
|
||||||
logger.info("START Follow from: {} to {}", param.targetActor, param.actor)
|
logger.info("START Follow from: {} to {}", param.targetActor, param.actor)
|
||||||
|
|
||||||
val targetEntity = actorQueryService.findByUrl(param.targetActor)
|
val targetEntity =
|
||||||
|
actorRepository.findByUrl(param.targetActor) ?: throw UserNotFoundException.withUrl(param.targetActor)
|
||||||
val followActorEntity =
|
val followActorEntity =
|
||||||
actorQueryService.findByUrl(follow.actor)
|
actorRepository.findByUrl(follow.actor) ?: throw UserNotFoundException.withUrl(follow.actor)
|
||||||
|
|
||||||
relationshipService.followRequest(followActorEntity.id, targetEntity.id)
|
relationshipService.followRequest(followActorEntity.id, targetEntity.id)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package dev.usbharu.hideout.activitypub.service.activity.like
|
package dev.usbharu.hideout.activitypub.service.activity.like
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.reaction.Reaction
|
import dev.usbharu.hideout.core.domain.model.reaction.Reaction
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverReactionJob
|
import dev.usbharu.hideout.core.external.job.DeliverReactionJob
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverRemoveReactionJob
|
import dev.usbharu.hideout.core.external.job.DeliverRemoveReactionJob
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.query.FollowerQueryService
|
import dev.usbharu.hideout.core.query.FollowerQueryService
|
||||||
import dev.usbharu.hideout.core.query.PostQueryService
|
import dev.usbharu.hideout.core.query.PostQueryService
|
||||||
import dev.usbharu.hideout.core.service.job.JobQueueParentService
|
import dev.usbharu.hideout.core.service.job.JobQueueParentService
|
||||||
|
@ -19,14 +20,14 @@ interface APReactionService {
|
||||||
@Service
|
@Service
|
||||||
class APReactionServiceImpl(
|
class APReactionServiceImpl(
|
||||||
private val jobQueueParentService: JobQueueParentService,
|
private val jobQueueParentService: JobQueueParentService,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val followerQueryService: FollowerQueryService,
|
private val followerQueryService: FollowerQueryService,
|
||||||
private val postQueryService: PostQueryService,
|
private val postQueryService: PostQueryService,
|
||||||
|
private val actorRepository: ActorRepository,
|
||||||
@Qualifier("activitypub") private val objectMapper: ObjectMapper
|
@Qualifier("activitypub") private val objectMapper: ObjectMapper
|
||||||
) : APReactionService {
|
) : APReactionService {
|
||||||
override suspend fun reaction(like: Reaction) {
|
override suspend fun reaction(like: Reaction) {
|
||||||
val followers = followerQueryService.findFollowersById(like.actorId)
|
val followers = followerQueryService.findFollowersById(like.actorId)
|
||||||
val user = actorQueryService.findById(like.actorId)
|
val user = actorRepository.findById(like.actorId) ?: throw UserNotFoundException.withId(like.actorId)
|
||||||
val post =
|
val post =
|
||||||
postQueryService.findById(like.postId)
|
postQueryService.findById(like.postId)
|
||||||
followers.forEach { follower ->
|
followers.forEach { follower ->
|
||||||
|
@ -42,7 +43,7 @@ class APReactionServiceImpl(
|
||||||
|
|
||||||
override suspend fun removeReaction(like: Reaction) {
|
override suspend fun removeReaction(like: Reaction) {
|
||||||
val followers = followerQueryService.findFollowersById(like.actorId)
|
val followers = followerQueryService.findFollowersById(like.actorId)
|
||||||
val user = actorQueryService.findById(like.actorId)
|
val user = actorRepository.findById(like.actorId) ?: throw UserNotFoundException.withId(like.actorId)
|
||||||
val post =
|
val post =
|
||||||
postQueryService.findById(like.postId)
|
postQueryService.findById(like.postId)
|
||||||
followers.forEach { follower ->
|
followers.forEach { follower ->
|
||||||
|
|
|
@ -4,21 +4,21 @@ import dev.usbharu.hideout.activitypub.domain.model.Like
|
||||||
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
||||||
import dev.usbharu.hideout.application.config.ApplicationConfig
|
import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverReactionJob
|
import dev.usbharu.hideout.core.external.job.DeliverReactionJob
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverReactionJobParam
|
import dev.usbharu.hideout.core.external.job.DeliverReactionJobParam
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.service.job.JobProcessor
|
import dev.usbharu.hideout.core.service.job.JobProcessor
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class ApReactionJobProcessor(
|
class ApReactionJobProcessor(
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val apRequestService: APRequestService,
|
private val apRequestService: APRequestService,
|
||||||
private val applicationConfig: ApplicationConfig,
|
private val applicationConfig: ApplicationConfig,
|
||||||
private val transaction: Transaction
|
private val transaction: Transaction,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) : JobProcessor<DeliverReactionJobParam, DeliverReactionJob> {
|
) : JobProcessor<DeliverReactionJobParam, DeliverReactionJob> {
|
||||||
override suspend fun process(param: DeliverReactionJobParam): Unit = transaction.transaction {
|
override suspend fun process(param: DeliverReactionJobParam): Unit = transaction.transaction {
|
||||||
val signer = actorQueryService.findByUrl(param.actor)
|
val signer = actorRepository.findByUrl(param.actor)
|
||||||
|
|
||||||
apRequestService.apPost(
|
apRequestService.apPost(
|
||||||
param.inbox,
|
param.inbox,
|
||||||
|
|
|
@ -7,25 +7,25 @@ import dev.usbharu.hideout.activitypub.domain.model.Undo
|
||||||
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
||||||
import dev.usbharu.hideout.application.config.ApplicationConfig
|
import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverRemoveReactionJob
|
import dev.usbharu.hideout.core.external.job.DeliverRemoveReactionJob
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverRemoveReactionJobParam
|
import dev.usbharu.hideout.core.external.job.DeliverRemoveReactionJobParam
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.service.job.JobProcessor
|
import dev.usbharu.hideout.core.service.job.JobProcessor
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class ApRemoveReactionJobProcessor(
|
class ApRemoveReactionJobProcessor(
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val transaction: Transaction,
|
private val transaction: Transaction,
|
||||||
private val objectMapper: ObjectMapper,
|
private val objectMapper: ObjectMapper,
|
||||||
private val apRequestService: APRequestService,
|
private val apRequestService: APRequestService,
|
||||||
private val applicationConfig: ApplicationConfig
|
private val applicationConfig: ApplicationConfig,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) : JobProcessor<DeliverRemoveReactionJobParam, DeliverRemoveReactionJob> {
|
) : JobProcessor<DeliverRemoveReactionJobParam, DeliverRemoveReactionJob> {
|
||||||
override suspend fun process(param: DeliverRemoveReactionJobParam): Unit = transaction.transaction {
|
override suspend fun process(param: DeliverRemoveReactionJobParam): Unit = transaction.transaction {
|
||||||
val like = objectMapper.readValue<Like>(param.like)
|
val like = objectMapper.readValue<Like>(param.like)
|
||||||
|
|
||||||
val signer = actorQueryService.findByUrl(param.actor)
|
val signer = actorRepository.findByUrl(param.actor)
|
||||||
|
|
||||||
apRequestService.apPost(
|
apRequestService.apPost(
|
||||||
param.inbox,
|
param.inbox,
|
||||||
|
|
|
@ -2,22 +2,22 @@ package dev.usbharu.hideout.activitypub.service.activity.reject
|
||||||
|
|
||||||
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverRejectJob
|
import dev.usbharu.hideout.core.external.job.DeliverRejectJob
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverRejectJobParam
|
import dev.usbharu.hideout.core.external.job.DeliverRejectJobParam
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.service.job.JobProcessor
|
import dev.usbharu.hideout.core.service.job.JobProcessor
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
class APDeliverRejectJobProcessor(
|
class APDeliverRejectJobProcessor(
|
||||||
private val apRequestService: APRequestService,
|
private val apRequestService: APRequestService,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val deliverRejectJob: DeliverRejectJob,
|
private val deliverRejectJob: DeliverRejectJob,
|
||||||
private val transaction: Transaction
|
private val transaction: Transaction,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) :
|
) :
|
||||||
JobProcessor<DeliverRejectJobParam, DeliverRejectJob> {
|
JobProcessor<DeliverRejectJobParam, DeliverRejectJob> {
|
||||||
override suspend fun process(param: DeliverRejectJobParam): Unit = transaction.transaction {
|
override suspend fun process(param: DeliverRejectJobParam): Unit = transaction.transaction {
|
||||||
apRequestService.apPost(param.inbox, param.reject, actorQueryService.findById(param.signer))
|
apRequestService.apPost(param.inbox, param.reject, actorRepository.findById(param.signer))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun job(): DeliverRejectJob = deliverRejectJob
|
override fun job(): DeliverRejectJob = deliverRejectJob
|
||||||
|
|
|
@ -6,15 +6,16 @@ import dev.usbharu.hideout.activitypub.service.common.AbstractActivityPubProcess
|
||||||
import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext
|
import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext
|
||||||
import dev.usbharu.hideout.activitypub.service.common.ActivityType
|
import dev.usbharu.hideout.activitypub.service.common.ActivityType
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class ApRejectProcessor(
|
class ApRejectProcessor(
|
||||||
private val relationshipService: RelationshipService,
|
private val relationshipService: RelationshipService,
|
||||||
private val actorQueryService: ActorQueryService,
|
transaction: Transaction,
|
||||||
transaction: Transaction
|
private val actorRepository: ActorRepository
|
||||||
) :
|
) :
|
||||||
AbstractActivityPubProcessor<Reject>(transaction) {
|
AbstractActivityPubProcessor<Reject>(transaction) {
|
||||||
override suspend fun internalProcess(activity: ActivityPubProcessContext<Reject>) {
|
override suspend fun internalProcess(activity: ActivityPubProcessContext<Reject>) {
|
||||||
|
@ -26,13 +27,15 @@ class ApRejectProcessor(
|
||||||
}
|
}
|
||||||
when (activityType) {
|
when (activityType) {
|
||||||
"Follow" -> {
|
"Follow" -> {
|
||||||
val user = actorQueryService.findByUrl(activity.activity.actor)
|
val user = actorRepository.findByUrl(activity.activity.actor) ?: throw UserNotFoundException.withUrl(
|
||||||
|
activity.activity.actor
|
||||||
|
)
|
||||||
|
|
||||||
activity.activity.apObject as Follow
|
activity.activity.apObject as Follow
|
||||||
|
|
||||||
val actor = activity.activity.apObject.actor
|
val actor = activity.activity.apObject.actor
|
||||||
|
|
||||||
val target = actorQueryService.findByUrl(actor)
|
val target = actorRepository.findByUrl(actor) ?: throw UserNotFoundException.withUrl(actor)
|
||||||
|
|
||||||
logger.debug("REJECT Follow user {} target {}", user.url, target.url)
|
logger.debug("REJECT Follow user {} target {}", user.url, target.url)
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@ package dev.usbharu.hideout.activitypub.service.activity.undo
|
||||||
|
|
||||||
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverUndoJob
|
import dev.usbharu.hideout.core.external.job.DeliverUndoJob
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverUndoJobParam
|
import dev.usbharu.hideout.core.external.job.DeliverUndoJobParam
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.service.job.JobProcessor
|
import dev.usbharu.hideout.core.service.job.JobProcessor
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -12,11 +12,11 @@ import org.springframework.stereotype.Service
|
||||||
class APDeliverUndoJobProcessor(
|
class APDeliverUndoJobProcessor(
|
||||||
private val deliverUndoJob: DeliverUndoJob,
|
private val deliverUndoJob: DeliverUndoJob,
|
||||||
private val apRequestService: APRequestService,
|
private val apRequestService: APRequestService,
|
||||||
private val actorQueryService: ActorQueryService,
|
private val transaction: Transaction,
|
||||||
private val transaction: Transaction
|
private val actorRepository: ActorRepository
|
||||||
) : JobProcessor<DeliverUndoJobParam, DeliverUndoJob> {
|
) : JobProcessor<DeliverUndoJobParam, DeliverUndoJob> {
|
||||||
override suspend fun process(param: DeliverUndoJobParam): Unit = transaction.transaction {
|
override suspend fun process(param: DeliverUndoJobParam): Unit = transaction.transaction {
|
||||||
apRequestService.apPost(param.inbox, param.undo, actorQueryService.findById(param.signer))
|
apRequestService.apPost(param.inbox, param.undo, actorRepository.findById(param.signer))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun job(): DeliverUndoJob = deliverUndoJob
|
override fun job(): DeliverUndoJob = deliverUndoJob
|
||||||
|
|
|
@ -7,7 +7,9 @@ import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext
|
||||||
import dev.usbharu.hideout.activitypub.service.common.ActivityType
|
import dev.usbharu.hideout.activitypub.service.common.ActivityType
|
||||||
import dev.usbharu.hideout.activitypub.service.objects.user.APUserService
|
import dev.usbharu.hideout.activitypub.service.objects.user.APUserService
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
|
import dev.usbharu.hideout.core.domain.exception.resource.local.LocalUserNotFoundException
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.query.PostQueryService
|
import dev.usbharu.hideout.core.query.PostQueryService
|
||||||
import dev.usbharu.hideout.core.service.reaction.ReactionService
|
import dev.usbharu.hideout.core.service.reaction.ReactionService
|
||||||
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
||||||
|
@ -17,10 +19,10 @@ import org.springframework.stereotype.Service
|
||||||
class APUndoProcessor(
|
class APUndoProcessor(
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val apUserService: APUserService,
|
private val apUserService: APUserService,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val relationshipService: RelationshipService,
|
private val relationshipService: RelationshipService,
|
||||||
private val postQueryService: PostQueryService,
|
private val postQueryService: PostQueryService,
|
||||||
private val reactionService: ReactionService
|
private val reactionService: ReactionService,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) :
|
) :
|
||||||
AbstractActivityPubProcessor<Undo>(transaction) {
|
AbstractActivityPubProcessor<Undo>(transaction) {
|
||||||
override suspend fun internalProcess(activity: ActivityPubProcessContext<Undo>) {
|
override suspend fun internalProcess(activity: ActivityPubProcessContext<Undo>) {
|
||||||
|
@ -35,9 +37,9 @@ class APUndoProcessor(
|
||||||
"Follow" -> {
|
"Follow" -> {
|
||||||
val follow = undo.apObject as Follow
|
val follow = undo.apObject as Follow
|
||||||
|
|
||||||
apUserService.fetchPerson(undo.actor, follow.apObject)
|
val follower = apUserService.fetchPersonWithEntity(undo.actor, follow.apObject).second
|
||||||
val follower = actorQueryService.findByUrl(undo.actor)
|
val target =
|
||||||
val target = actorQueryService.findByUrl(follow.apObject)
|
actorRepository.findByUrl(follow.apObject) ?: throw UserNotFoundException.withUrl(follow.apObject)
|
||||||
|
|
||||||
relationshipService.unfollow(follower.id, target.id)
|
relationshipService.unfollow(follower.id, target.id)
|
||||||
return
|
return
|
||||||
|
@ -47,7 +49,8 @@ class APUndoProcessor(
|
||||||
val block = undo.apObject as Block
|
val block = undo.apObject as Block
|
||||||
|
|
||||||
val blocker = apUserService.fetchPersonWithEntity(undo.actor, block.apObject).second
|
val blocker = apUserService.fetchPersonWithEntity(undo.actor, block.apObject).second
|
||||||
val target = actorQueryService.findByUrl(block.apObject)
|
val target =
|
||||||
|
actorRepository.findByUrl(block.apObject) ?: throw UserNotFoundException.withUrl(block.apObject)
|
||||||
|
|
||||||
relationshipService.unblock(blocker.id, target.id)
|
relationshipService.unblock(blocker.id, target.id)
|
||||||
return
|
return
|
||||||
|
@ -66,7 +69,8 @@ class APUndoProcessor(
|
||||||
}
|
}
|
||||||
|
|
||||||
val accepter = apUserService.fetchPersonWithEntity(undo.actor, acceptObject).second
|
val accepter = apUserService.fetchPersonWithEntity(undo.actor, acceptObject).second
|
||||||
val target = actorQueryService.findByUrl(acceptObject)
|
val target =
|
||||||
|
actorRepository.findByUrl(acceptObject) ?: throw UserNotFoundException.withUrl(acceptObject)
|
||||||
|
|
||||||
relationshipService.rejectFollowRequest(accepter.id, target.id)
|
relationshipService.rejectFollowRequest(accepter.id, target.id)
|
||||||
return
|
return
|
||||||
|
@ -77,7 +81,9 @@ class APUndoProcessor(
|
||||||
|
|
||||||
val post = postQueryService.findByUrl(like.apObject)
|
val post = postQueryService.findByUrl(like.apObject)
|
||||||
|
|
||||||
val actor = actorQueryService.findByUrl(like.actor)
|
val signer =
|
||||||
|
actorRepository.findById(post.actorId) ?: throw LocalUserNotFoundException.withId(post.actorId)
|
||||||
|
val actor = apUserService.fetchPersonWithEntity(like.actor, signer.url).second
|
||||||
|
|
||||||
reactionService.receiveRemoveReaction(actor.id, post.id)
|
reactionService.receiveRemoveReaction(actor.id, post.id)
|
||||||
return
|
return
|
||||||
|
|
|
@ -7,10 +7,8 @@ import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext
|
||||||
import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessor
|
import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessor
|
||||||
import dev.usbharu.hideout.activitypub.service.objects.user.APUserService
|
import dev.usbharu.hideout.activitypub.service.objects.user.APUserService
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
|
||||||
import dev.usbharu.hideout.core.external.job.InboxJob
|
import dev.usbharu.hideout.core.external.job.InboxJob
|
||||||
import dev.usbharu.hideout.core.external.job.InboxJobParam
|
import dev.usbharu.hideout.core.external.job.InboxJobParam
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.service.job.JobProcessor
|
import dev.usbharu.hideout.core.service.job.JobProcessor
|
||||||
import dev.usbharu.hideout.util.RsaUtil
|
import dev.usbharu.hideout.util.RsaUtil
|
||||||
import dev.usbharu.httpsignature.common.HttpHeaders
|
import dev.usbharu.httpsignature.common.HttpHeaders
|
||||||
|
@ -29,7 +27,6 @@ class InboxJobProcessor(
|
||||||
private val objectMapper: ObjectMapper,
|
private val objectMapper: ObjectMapper,
|
||||||
private val signatureHeaderParser: SignatureHeaderParser,
|
private val signatureHeaderParser: SignatureHeaderParser,
|
||||||
private val signatureVerifier: HttpSignatureVerifier,
|
private val signatureVerifier: HttpSignatureVerifier,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val apUserService: APUserService,
|
private val apUserService: APUserService,
|
||||||
private val transaction: Transaction
|
private val transaction: Transaction
|
||||||
) : JobProcessor<InboxJobParam, InboxJob> {
|
) : JobProcessor<InboxJobParam, InboxJob> {
|
||||||
|
@ -37,7 +34,8 @@ class InboxJobProcessor(
|
||||||
private suspend fun verifyHttpSignature(
|
private suspend fun verifyHttpSignature(
|
||||||
httpRequest: HttpRequest,
|
httpRequest: HttpRequest,
|
||||||
signature: Signature,
|
signature: Signature,
|
||||||
transaction: Transaction
|
transaction: Transaction,
|
||||||
|
actor: String
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val requiredHeaders = when (httpRequest.method) {
|
val requiredHeaders = when (httpRequest.method) {
|
||||||
HttpMethod.GET -> getRequiredHeaders
|
HttpMethod.GET -> getRequiredHeaders
|
||||||
|
@ -49,11 +47,7 @@ class InboxJobProcessor(
|
||||||
}
|
}
|
||||||
|
|
||||||
val user = transaction.transaction {
|
val user = transaction.transaction {
|
||||||
try {
|
apUserService.fetchPersonWithEntity(actor).second
|
||||||
actorQueryService.findByKeyId(signature.keyId)
|
|
||||||
} catch (_: FailedToGetResourcesException) {
|
|
||||||
apUserService.fetchPersonWithEntity(signature.keyId).second
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("TooGenericExceptionCaught")
|
@Suppress("TooGenericExceptionCaught")
|
||||||
|
@ -97,7 +91,10 @@ class InboxJobProcessor(
|
||||||
|
|
||||||
logger.debug("Has signature? {}", signature != null)
|
logger.debug("Has signature? {}", signature != null)
|
||||||
|
|
||||||
val verify = signature?.let { verifyHttpSignature(httpRequest, it, transaction) } ?: false
|
|
||||||
|
//todo 不正なactorを取得してしまわないようにする
|
||||||
|
val verify =
|
||||||
|
signature?.let { verifyHttpSignature(httpRequest, it, transaction, jsonNode["actor"].textValue()) } ?: false
|
||||||
|
|
||||||
logger.debug("Is verifying success? {}", verify)
|
logger.debug("Is verifying success? {}", verify)
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.fasterxml.jackson.module.kotlin.readValue
|
||||||
import dev.usbharu.hideout.activitypub.domain.model.Create
|
import dev.usbharu.hideout.activitypub.domain.model.Create
|
||||||
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverPostJob
|
import dev.usbharu.hideout.core.external.job.DeliverPostJob
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverPostJobParam
|
import dev.usbharu.hideout.core.external.job.DeliverPostJobParam
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.service.job.JobProcessor
|
import dev.usbharu.hideout.core.service.job.JobProcessor
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -16,13 +16,13 @@ import org.springframework.stereotype.Service
|
||||||
class ApNoteJobProcessor(
|
class ApNoteJobProcessor(
|
||||||
private val transaction: Transaction,
|
private val transaction: Transaction,
|
||||||
private val objectMapper: ObjectMapper,
|
private val objectMapper: ObjectMapper,
|
||||||
private val actorQueryService: ActorQueryService,
|
private val apRequestService: APRequestService,
|
||||||
private val apRequestService: APRequestService
|
private val actorRepository: ActorRepository
|
||||||
) : JobProcessor<DeliverPostJobParam, DeliverPostJob> {
|
) : JobProcessor<DeliverPostJobParam, DeliverPostJob> {
|
||||||
override suspend fun process(param: DeliverPostJobParam) {
|
override suspend fun process(param: DeliverPostJobParam) {
|
||||||
val create = objectMapper.readValue<Create>(param.create)
|
val create = objectMapper.readValue<Create>(param.create)
|
||||||
transaction.transaction {
|
transaction.transaction {
|
||||||
val signer = actorQueryService.findByUrl(param.actor)
|
val signer = actorRepository.findByUrl(param.actor)
|
||||||
|
|
||||||
logger.debug("CreateNoteJob: actor: {} create: {} inbox: {}", param.actor, create, param.inbox)
|
logger.debug("CreateNoteJob: actor: {} create: {} inbox: {}", param.actor, create, param.inbox)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package dev.usbharu.hideout.activitypub.service.objects.user
|
package dev.usbharu.hideout.activitypub.service.objects.user
|
||||||
|
|
||||||
import dev.usbharu.hideout.activitypub.domain.exception.IllegalActivityPubObjectException
|
|
||||||
import dev.usbharu.hideout.activitypub.domain.model.Image
|
import dev.usbharu.hideout.activitypub.domain.model.Image
|
||||||
import dev.usbharu.hideout.activitypub.domain.model.Key
|
import dev.usbharu.hideout.activitypub.domain.model.Key
|
||||||
import dev.usbharu.hideout.activitypub.domain.model.Person
|
import dev.usbharu.hideout.activitypub.domain.model.Person
|
||||||
|
@ -8,9 +7,9 @@ import dev.usbharu.hideout.activitypub.service.common.APResourceResolveService
|
||||||
import dev.usbharu.hideout.activitypub.service.common.resolve
|
import dev.usbharu.hideout.activitypub.service.common.resolve
|
||||||
import dev.usbharu.hideout.application.config.ApplicationConfig
|
import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
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
|
||||||
|
@ -34,16 +33,17 @@ interface APUserService {
|
||||||
@Service
|
@Service
|
||||||
class APUserServiceImpl(
|
class APUserServiceImpl(
|
||||||
private val userService: UserService,
|
private val userService: UserService,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val transaction: Transaction,
|
private val transaction: Transaction,
|
||||||
private val applicationConfig: ApplicationConfig,
|
private val applicationConfig: ApplicationConfig,
|
||||||
private val apResourceResolveService: APResourceResolveService
|
private val apResourceResolveService: APResourceResolveService,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) :
|
) :
|
||||||
APUserService {
|
APUserService {
|
||||||
|
|
||||||
override suspend fun getPersonByName(name: String): Person {
|
override suspend fun getPersonByName(name: String): Person {
|
||||||
val userEntity = transaction.transaction {
|
val userEntity = transaction.transaction {
|
||||||
actorQueryService.findByNameAndDomain(name, applicationConfig.url.host)
|
actorRepository.findByNameAndDomain(name, applicationConfig.url.host)
|
||||||
|
?: throw UserNotFoundException.withNameAndDomain(name, applicationConfig.url.host)
|
||||||
}
|
}
|
||||||
// TODO: JOINで書き直し
|
// TODO: JOINで書き直し
|
||||||
val userUrl = "${applicationConfig.url}/users/$name"
|
val userUrl = "${applicationConfig.url}/users/$name"
|
||||||
|
@ -78,38 +78,41 @@ class APUserServiceImpl(
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
override suspend fun fetchPersonWithEntity(url: String, targetActor: String?): Pair<Person, Actor> {
|
override suspend fun fetchPersonWithEntity(url: String, targetActor: String?): Pair<Person, Actor> {
|
||||||
return try {
|
val userEntity = actorRepository.findByUrl(url)
|
||||||
val userEntity = actorQueryService.findByUrl(url)
|
|
||||||
val id = userEntity.url
|
|
||||||
return entityToPerson(userEntity, id) to userEntity
|
|
||||||
} catch (ignore: FailedToGetResourcesException) {
|
|
||||||
val person = apResourceResolveService.resolve<Person>(url, null as Long?)
|
|
||||||
|
|
||||||
val id = person.id
|
if (userEntity != null) {
|
||||||
try {
|
return entityToPerson(userEntity, userEntity.url) to userEntity
|
||||||
val userEntity = actorQueryService.findByUrl(id)
|
|
||||||
return entityToPerson(userEntity, id) to userEntity
|
|
||||||
} catch (_: FailedToGetResourcesException) {
|
|
||||||
}
|
|
||||||
person to userService.createRemoteUser(
|
|
||||||
RemoteUserCreateDto(
|
|
||||||
name = person.preferredUsername
|
|
||||||
?: throw IllegalActivityPubObjectException("preferredUsername is null"),
|
|
||||||
domain = id.substringAfter("://").substringBefore("/"),
|
|
||||||
screenName = person.name ?: person.preferredUsername,
|
|
||||||
description = person.summary.orEmpty(),
|
|
||||||
inbox = person.inbox,
|
|
||||||
outbox = person.outbox,
|
|
||||||
url = id,
|
|
||||||
publicKey = person.publicKey.publicKeyPem,
|
|
||||||
keyId = person.publicKey.id,
|
|
||||||
following = person.following,
|
|
||||||
followers = person.followers,
|
|
||||||
sharedInbox = person.endpoints["sharedInbox"],
|
|
||||||
locked = person.manuallyApprovesFollowers
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val person = apResourceResolveService.resolve<Person>(url, null as Long?)
|
||||||
|
|
||||||
|
val id = person.id
|
||||||
|
|
||||||
|
val actor = actorRepository.findByUrlWithLock(id)
|
||||||
|
|
||||||
|
if (actor != null) {
|
||||||
|
return person to actor
|
||||||
|
}
|
||||||
|
|
||||||
|
return person to userService.createRemoteUser(
|
||||||
|
RemoteUserCreateDto(
|
||||||
|
name = person.preferredUsername,
|
||||||
|
domain = id.substringAfter("://").substringBefore("/"),
|
||||||
|
screenName = person.name ?: person.preferredUsername,
|
||||||
|
description = person.summary.orEmpty(),
|
||||||
|
inbox = person.inbox,
|
||||||
|
outbox = person.outbox,
|
||||||
|
url = id,
|
||||||
|
publicKey = person.publicKey.publicKeyPem,
|
||||||
|
keyId = person.publicKey.id,
|
||||||
|
following = person.following,
|
||||||
|
followers = person.followers,
|
||||||
|
sharedInbox = person.endpoints["sharedInbox"],
|
||||||
|
locked = person.manuallyApprovesFollowers
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun entityToPerson(
|
private fun entityToPerson(
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package dev.usbharu.hideout.activitypub.service.webfinger
|
package dev.usbharu.hideout.activitypub.service.webfinger
|
||||||
|
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -11,11 +12,17 @@ interface WebFingerApiService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class WebFingerApiServiceImpl(private val transaction: Transaction, private val actorQueryService: ActorQueryService) :
|
class WebFingerApiServiceImpl(
|
||||||
|
private val transaction: Transaction,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
|
) :
|
||||||
WebFingerApiService {
|
WebFingerApiService {
|
||||||
override suspend fun findByNameAndDomain(name: String, domain: String): Actor {
|
override suspend fun findByNameAndDomain(name: String, domain: String): Actor {
|
||||||
return transaction.transaction {
|
return transaction.transaction {
|
||||||
actorQueryService.findByNameAndDomain(name, domain)
|
actorRepository.findByNameAndDomain(name, domain) ?: throw UserNotFoundException.withNameAndDomain(
|
||||||
|
name,
|
||||||
|
domain
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,19 +7,18 @@ import com.nimbusds.jose.jwk.source.ImmutableJWKSet
|
||||||
import com.nimbusds.jose.jwk.source.JWKSource
|
import com.nimbusds.jose.jwk.source.JWKSource
|
||||||
import com.nimbusds.jose.proc.SecurityContext
|
import com.nimbusds.jose.proc.SecurityContext
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.infrastructure.springframework.httpsignature.HttpSignatureFilter
|
import dev.usbharu.hideout.core.infrastructure.springframework.httpsignature.HttpSignatureFilter
|
||||||
import dev.usbharu.hideout.core.infrastructure.springframework.httpsignature.HttpSignatureUserDetailsService
|
import dev.usbharu.hideout.core.infrastructure.springframework.httpsignature.HttpSignatureUserDetailsService
|
||||||
import dev.usbharu.hideout.core.infrastructure.springframework.httpsignature.HttpSignatureVerifierComposite
|
import dev.usbharu.hideout.core.infrastructure.springframework.httpsignature.HttpSignatureVerifierComposite
|
||||||
import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.UserDetailsImpl
|
import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.UserDetailsImpl
|
||||||
import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.UserDetailsServiceImpl
|
import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.UserDetailsServiceImpl
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.util.RsaUtil
|
import dev.usbharu.hideout.util.RsaUtil
|
||||||
import dev.usbharu.hideout.util.hasAnyScope
|
import dev.usbharu.hideout.util.hasAnyScope
|
||||||
import dev.usbharu.httpsignature.sign.RsaSha256HttpSignatureSigner
|
import dev.usbharu.httpsignature.sign.RsaSha256HttpSignatureSigner
|
||||||
import dev.usbharu.httpsignature.verify.DefaultSignatureHeaderParser
|
import dev.usbharu.httpsignature.verify.DefaultSignatureHeaderParser
|
||||||
import dev.usbharu.httpsignature.verify.RsaSha256HttpSignatureVerifier
|
import dev.usbharu.httpsignature.verify.RsaSha256HttpSignatureVerifier
|
||||||
import jakarta.annotation.PostConstruct
|
import jakarta.annotation.PostConstruct
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
||||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer
|
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||||
|
@ -68,9 +67,6 @@ import java.util.*
|
||||||
@Suppress("FunctionMaxLength", "TooManyFunctions")
|
@Suppress("FunctionMaxLength", "TooManyFunctions")
|
||||||
class SecurityConfig {
|
class SecurityConfig {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private lateinit var actorQueryService: ActorQueryService
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
fun authenticationManager(authenticationConfiguration: AuthenticationConfiguration): AuthenticationManager? =
|
fun authenticationManager(authenticationConfiguration: AuthenticationConfiguration): AuthenticationManager? =
|
||||||
authenticationConfiguration.authenticationManager
|
authenticationConfiguration.authenticationManager
|
||||||
|
@ -130,12 +126,14 @@ class SecurityConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Order(1)
|
@Order(1)
|
||||||
fun httpSignatureAuthenticationProvider(transaction: Transaction): PreAuthenticatedAuthenticationProvider {
|
fun httpSignatureAuthenticationProvider(
|
||||||
|
transaction: Transaction,
|
||||||
|
actorRepository: ActorRepository
|
||||||
|
): PreAuthenticatedAuthenticationProvider {
|
||||||
val provider = PreAuthenticatedAuthenticationProvider()
|
val provider = PreAuthenticatedAuthenticationProvider()
|
||||||
val signatureHeaderParser = DefaultSignatureHeaderParser()
|
val signatureHeaderParser = DefaultSignatureHeaderParser()
|
||||||
provider.setPreAuthenticatedUserDetailsService(
|
provider.setPreAuthenticatedUserDetailsService(
|
||||||
HttpSignatureUserDetailsService(
|
HttpSignatureUserDetailsService(
|
||||||
actorQueryService,
|
|
||||||
HttpSignatureVerifierComposite(
|
HttpSignatureVerifierComposite(
|
||||||
mapOf(
|
mapOf(
|
||||||
"rsa-sha256" to RsaSha256HttpSignatureVerifier(
|
"rsa-sha256" to RsaSha256HttpSignatureVerifier(
|
||||||
|
@ -145,7 +143,8 @@ class SecurityConfig {
|
||||||
signatureHeaderParser
|
signatureHeaderParser
|
||||||
),
|
),
|
||||||
transaction,
|
transaction,
|
||||||
signatureHeaderParser
|
signatureHeaderParser,
|
||||||
|
actorRepository
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
provider.setUserDetailsChecker(AccountStatusUserDetailsChecker())
|
provider.setUserDetailsChecker(AccountStatusUserDetailsChecker())
|
||||||
|
|
|
@ -6,12 +6,11 @@ import org.jetbrains.exposed.sql.StdOutSqlLogger
|
||||||
import org.jetbrains.exposed.sql.addLogger
|
import org.jetbrains.exposed.sql.addLogger
|
||||||
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
|
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.sql.Connection
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class ExposedTransaction : Transaction {
|
class ExposedTransaction : Transaction {
|
||||||
override suspend fun <T> transaction(block: suspend () -> T): T {
|
override suspend fun <T> transaction(block: suspend () -> T): T {
|
||||||
return newSuspendedTransaction(MDCContext(), transactionIsolation = Connection.TRANSACTION_SERIALIZABLE) {
|
return newSuspendedTransaction(MDCContext()) {
|
||||||
addLogger(StdOutSqlLogger)
|
addLogger(StdOutSqlLogger)
|
||||||
block()
|
block()
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package dev.usbharu.hideout.core.domain.exception
|
||||||
|
|
||||||
|
import java.io.Serial
|
||||||
|
|
||||||
|
open class HideoutException : RuntimeException {
|
||||||
|
constructor() : super()
|
||||||
|
constructor(message: String?) : super(message)
|
||||||
|
constructor(message: String?, cause: Throwable?) : super(message, cause)
|
||||||
|
constructor(cause: Throwable?) : super(cause)
|
||||||
|
constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super(
|
||||||
|
message,
|
||||||
|
cause,
|
||||||
|
enableSuppression,
|
||||||
|
writableStackTrace
|
||||||
|
)
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@Serial
|
||||||
|
private const val serialVersionUID: Long = 8506638570017469956L
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package dev.usbharu.hideout.core.domain.exception.resource
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.exception.HideoutException
|
||||||
|
|
||||||
|
open class NotFoundException : HideoutException {
|
||||||
|
constructor() : super()
|
||||||
|
constructor(message: String?) : super(message)
|
||||||
|
constructor(message: String?, cause: Throwable?) : super(message, cause)
|
||||||
|
constructor(cause: Throwable?) : super(cause)
|
||||||
|
constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super(
|
||||||
|
message,
|
||||||
|
cause,
|
||||||
|
enableSuppression,
|
||||||
|
writableStackTrace
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package dev.usbharu.hideout.core.domain.exception.resource
|
||||||
|
|
||||||
|
import java.io.Serial
|
||||||
|
|
||||||
|
open class UserNotFoundException : NotFoundException {
|
||||||
|
constructor() : super()
|
||||||
|
constructor(message: String?) : super(message)
|
||||||
|
constructor(message: String?, cause: Throwable?) : super(message, cause)
|
||||||
|
constructor(cause: Throwable?) : super(cause)
|
||||||
|
constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super(
|
||||||
|
message,
|
||||||
|
cause,
|
||||||
|
enableSuppression,
|
||||||
|
writableStackTrace
|
||||||
|
)
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@Serial
|
||||||
|
private const val serialVersionUID: Long = 3219433672235626200L
|
||||||
|
|
||||||
|
|
||||||
|
fun withName(string: String, throwable: Throwable? = null): UserNotFoundException =
|
||||||
|
UserNotFoundException("name: $string was not found.", throwable)
|
||||||
|
|
||||||
|
fun withId(id: Long, throwable: Throwable? = null): UserNotFoundException =
|
||||||
|
UserNotFoundException("id: $id was not found.", throwable)
|
||||||
|
|
||||||
|
fun withUrl(url: String, throwable: Throwable? = null): UserNotFoundException =
|
||||||
|
UserNotFoundException("url: $url was not found.", throwable)
|
||||||
|
|
||||||
|
fun withNameAndDomain(name: String, domain: String, throwable: Throwable? = null): UserNotFoundException =
|
||||||
|
UserNotFoundException("name: $name domain: $domain (@$name@$domain) was not found.", throwable)
|
||||||
|
|
||||||
|
fun withKeyId(keyId: String, throwable: Throwable? = null) =
|
||||||
|
UserNotFoundException("keyId: $keyId was not found.", throwable)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package dev.usbharu.hideout.core.domain.exception.resource.local
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
|
import java.io.Serial
|
||||||
|
|
||||||
|
class LocalUserNotFoundException : UserNotFoundException {
|
||||||
|
constructor() : super()
|
||||||
|
constructor(message: String?) : super(message)
|
||||||
|
constructor(message: String?, cause: Throwable?) : super(message, cause)
|
||||||
|
constructor(cause: Throwable?) : super(cause)
|
||||||
|
constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super(
|
||||||
|
message,
|
||||||
|
cause,
|
||||||
|
enableSuppression,
|
||||||
|
writableStackTrace
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@Serial
|
||||||
|
private const val serialVersionUID: Long = -4742548128672528145L
|
||||||
|
|
||||||
|
fun withName(string: String, throwable: Throwable? = null): LocalUserNotFoundException =
|
||||||
|
LocalUserNotFoundException("name: $string was not found.", throwable)
|
||||||
|
|
||||||
|
fun withId(id: Long, throwable: Throwable? = null): LocalUserNotFoundException =
|
||||||
|
LocalUserNotFoundException("id: $id was not found.", throwable)
|
||||||
|
|
||||||
|
fun withUrl(url: String, throwable: Throwable? = null): LocalUserNotFoundException =
|
||||||
|
LocalUserNotFoundException("url: $url was not found.", throwable)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,24 @@ interface ActorRepository {
|
||||||
|
|
||||||
suspend fun findById(id: Long): Actor?
|
suspend fun findById(id: Long): Actor?
|
||||||
|
|
||||||
|
suspend fun findByIdWithLock(id: Long): Actor?
|
||||||
|
|
||||||
|
suspend fun findAll(limit: Int, offset: Long): List<Actor>
|
||||||
|
|
||||||
|
suspend fun findByName(name: String): List<Actor>
|
||||||
|
|
||||||
|
suspend fun findByNameAndDomain(name: String, domain: String): Actor?
|
||||||
|
|
||||||
|
suspend fun findByNameAndDomainWithLock(name: String, domain: String): Actor?
|
||||||
|
|
||||||
|
suspend fun findByUrl(url: String): Actor?
|
||||||
|
|
||||||
|
suspend fun findByUrlWithLock(url: String): Actor?
|
||||||
|
|
||||||
|
suspend fun findByIds(ids: List<Long>): List<Actor>
|
||||||
|
|
||||||
|
suspend fun findByKeyId(keyId: String): Actor?
|
||||||
|
|
||||||
suspend fun delete(id: Long)
|
suspend fun delete(id: Long)
|
||||||
|
|
||||||
suspend fun nextId(): Long
|
suspend fun nextId(): Long
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
package dev.usbharu.hideout.core.infrastructure.exposedquery
|
|
||||||
|
|
||||||
import dev.usbharu.hideout.application.infrastructure.exposed.QueryMapper
|
|
||||||
import dev.usbharu.hideout.application.infrastructure.exposed.ResultRowMapper
|
|
||||||
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
|
||||||
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors
|
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.util.singleOr
|
|
||||||
import org.jetbrains.exposed.sql.and
|
|
||||||
import org.jetbrains.exposed.sql.select
|
|
||||||
import org.jetbrains.exposed.sql.selectAll
|
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import org.springframework.stereotype.Repository
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
class ActorQueryServiceImpl(
|
|
||||||
private val actorResultRowMapper: ResultRowMapper<Actor>,
|
|
||||||
private val actorQueryMapper: QueryMapper<Actor>
|
|
||||||
) : ActorQueryService {
|
|
||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(ActorQueryServiceImpl::class.java)
|
|
||||||
|
|
||||||
override suspend fun findAll(limit: Int, offset: Long): List<Actor> =
|
|
||||||
Actors.selectAll().limit(limit, offset).let(actorQueryMapper::map)
|
|
||||||
|
|
||||||
override suspend fun findById(id: Long): Actor = Actors.select { Actors.id eq id }
|
|
||||||
.singleOr { FailedToGetResourcesException("id: $id is duplicate or does not exist.", it) }
|
|
||||||
.let(actorResultRowMapper::map)
|
|
||||||
|
|
||||||
override suspend fun findByName(name: String): List<Actor> =
|
|
||||||
Actors.select { Actors.name eq name }.let(actorQueryMapper::map)
|
|
||||||
|
|
||||||
override suspend fun findByNameAndDomain(name: String, domain: String): Actor =
|
|
||||||
Actors
|
|
||||||
.select { Actors.name eq name and (Actors.domain eq domain) }
|
|
||||||
.singleOr {
|
|
||||||
FailedToGetResourcesException("name: $name,domain: $domain is duplicate or does not exist.", it)
|
|
||||||
}
|
|
||||||
.let(actorResultRowMapper::map)
|
|
||||||
|
|
||||||
override suspend fun findByUrl(url: String): Actor {
|
|
||||||
logger.trace("findByUrl url: $url")
|
|
||||||
return Actors.select { Actors.url eq url }
|
|
||||||
.singleOr { FailedToGetResourcesException("url: $url is duplicate or does not exist.", it) }
|
|
||||||
.let(actorResultRowMapper::map)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun findByIds(ids: List<Long>): List<Actor> =
|
|
||||||
Actors.select { Actors.id inList ids }.let(actorQueryMapper::map)
|
|
||||||
|
|
||||||
override suspend fun existByNameAndDomain(name: String, domain: String): Boolean =
|
|
||||||
Actors.select { Actors.name eq name and (Actors.domain eq domain) }.empty().not()
|
|
||||||
|
|
||||||
override suspend fun findByKeyId(keyId: String): Actor {
|
|
||||||
return Actors.select { Actors.keyId eq keyId }
|
|
||||||
.singleOr { FailedToGetResourcesException("keyId: $keyId is duplicate or does not exist.", it) }
|
|
||||||
.let(actorResultRowMapper::map)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,8 @@
|
||||||
package dev.usbharu.hideout.core.infrastructure.exposedquery
|
package dev.usbharu.hideout.core.infrastructure.exposedquery
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
||||||
|
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.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.query.FollowerQueryService
|
import dev.usbharu.hideout.core.query.FollowerQueryService
|
||||||
import dev.usbharu.hideout.core.query.RelationshipQueryService
|
import dev.usbharu.hideout.core.query.RelationshipQueryService
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
@ -10,11 +10,11 @@ import org.springframework.stereotype.Repository
|
||||||
@Repository
|
@Repository
|
||||||
class FollowerQueryServiceImpl(
|
class FollowerQueryServiceImpl(
|
||||||
private val relationshipQueryService: RelationshipQueryService,
|
private val relationshipQueryService: RelationshipQueryService,
|
||||||
private val actorQueryService: ActorQueryService,
|
private val relationshipRepository: RelationshipRepository,
|
||||||
private val relationshipRepository: RelationshipRepository
|
private val actorRepository: ActorRepository
|
||||||
) : FollowerQueryService {
|
) : FollowerQueryService {
|
||||||
override suspend fun findFollowersById(id: Long): List<Actor> {
|
override suspend fun findFollowersById(id: Long): List<Actor> {
|
||||||
return actorQueryService.findByIds(
|
return actorRepository.findByIds(
|
||||||
relationshipQueryService.findByTargetIdAndFollowing(id, true).map { it.actorId }
|
relationshipQueryService.findByTargetIdAndFollowing(id, true).map { it.actorId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package dev.usbharu.hideout.core.infrastructure.exposedrepository
|
package dev.usbharu.hideout.core.infrastructure.exposedrepository
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.application.infrastructure.exposed.QueryMapper
|
||||||
import dev.usbharu.hideout.application.infrastructure.exposed.ResultRowMapper
|
import dev.usbharu.hideout.application.infrastructure.exposed.ResultRowMapper
|
||||||
import dev.usbharu.hideout.application.service.id.IdGenerateService
|
import dev.usbharu.hideout.application.service.id.IdGenerateService
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
||||||
|
@ -12,12 +13,13 @@ import org.springframework.stereotype.Repository
|
||||||
@Repository
|
@Repository
|
||||||
class ActorRepositoryImpl(
|
class ActorRepositoryImpl(
|
||||||
private val idGenerateService: IdGenerateService,
|
private val idGenerateService: IdGenerateService,
|
||||||
private val actorResultRowMapper: ResultRowMapper<Actor>
|
private val actorResultRowMapper: ResultRowMapper<Actor>,
|
||||||
|
private val actorQueryMapper: QueryMapper<Actor>
|
||||||
) :
|
) :
|
||||||
ActorRepository {
|
ActorRepository {
|
||||||
|
|
||||||
override suspend fun save(actor: Actor): Actor {
|
override suspend fun save(actor: Actor): Actor {
|
||||||
val singleOrNull = Actors.select { Actors.id eq actor.id }.empty()
|
val singleOrNull = Actors.select { Actors.id eq actor.id }.forUpdate().empty()
|
||||||
if (singleOrNull) {
|
if (singleOrNull) {
|
||||||
Actors.insert {
|
Actors.insert {
|
||||||
it[id] = actor.id
|
it[id] = actor.id
|
||||||
|
@ -70,6 +72,41 @@ class ActorRepositoryImpl(
|
||||||
override suspend fun findById(id: Long): Actor? =
|
override suspend fun findById(id: Long): Actor? =
|
||||||
Actors.select { Actors.id eq id }.singleOrNull()?.let(actorResultRowMapper::map)
|
Actors.select { Actors.id eq id }.singleOrNull()?.let(actorResultRowMapper::map)
|
||||||
|
|
||||||
|
override suspend fun findByIdWithLock(id: Long): Actor? =
|
||||||
|
Actors.select { Actors.id eq id }.forUpdate().singleOrNull()?.let(actorResultRowMapper::map)
|
||||||
|
|
||||||
|
override suspend fun findAll(limit: Int, offset: Long): List<Actor> =
|
||||||
|
Actors.selectAll().limit(limit, offset).let(actorQueryMapper::map)
|
||||||
|
|
||||||
|
override suspend fun findByName(name: String): List<Actor> =
|
||||||
|
Actors.select { Actors.name eq name }.let(actorQueryMapper::map)
|
||||||
|
|
||||||
|
override suspend fun findByNameAndDomain(name: String, domain: String): Actor? = Actors
|
||||||
|
.select { Actors.name eq name and (Actors.domain eq domain) }
|
||||||
|
.singleOrNull()
|
||||||
|
?.let(actorResultRowMapper::map)
|
||||||
|
|
||||||
|
override suspend fun findByNameAndDomainWithLock(name: String, domain: String): Actor? = Actors
|
||||||
|
.select { Actors.name eq name and (Actors.domain eq domain) }
|
||||||
|
.forUpdate()
|
||||||
|
.singleOrNull()
|
||||||
|
?.let(actorResultRowMapper::map)
|
||||||
|
|
||||||
|
override suspend fun findByUrl(url: String): Actor? = Actors.select { Actors.url eq url }
|
||||||
|
.singleOrNull()
|
||||||
|
?.let(actorResultRowMapper::map)
|
||||||
|
|
||||||
|
override suspend fun findByUrlWithLock(url: String): Actor? = Actors.select { Actors.url eq url }.forUpdate()
|
||||||
|
.singleOrNull()
|
||||||
|
?.let(actorResultRowMapper::map)
|
||||||
|
|
||||||
|
override suspend fun findByIds(ids: List<Long>): List<Actor> =
|
||||||
|
Actors.select { Actors.id inList ids }.let(actorQueryMapper::map)
|
||||||
|
|
||||||
|
override suspend fun findByKeyId(keyId: String): Actor? = Actors.select { Actors.keyId eq keyId }
|
||||||
|
.singleOrNull()
|
||||||
|
?.let(actorResultRowMapper::map)
|
||||||
|
|
||||||
override suspend fun delete(id: Long) {
|
override suspend fun delete(id: Long) {
|
||||||
Actors.deleteWhere { Actors.id.eq(id) }
|
Actors.deleteWhere { Actors.id.eq(id) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package dev.usbharu.hideout.core.infrastructure.springframework.httpsignature
|
package dev.usbharu.hideout.core.infrastructure.springframework.httpsignature
|
||||||
|
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
|
||||||
import dev.usbharu.hideout.core.domain.exception.HttpSignatureVerifyException
|
import dev.usbharu.hideout.core.domain.exception.HttpSignatureVerifyException
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.util.RsaUtil
|
import dev.usbharu.hideout.util.RsaUtil
|
||||||
import dev.usbharu.httpsignature.common.HttpMethod
|
import dev.usbharu.httpsignature.common.HttpMethod
|
||||||
import dev.usbharu.httpsignature.common.HttpRequest
|
import dev.usbharu.httpsignature.common.HttpRequest
|
||||||
|
@ -20,10 +19,10 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException
|
||||||
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken
|
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken
|
||||||
|
|
||||||
class HttpSignatureUserDetailsService(
|
class HttpSignatureUserDetailsService(
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val httpSignatureVerifier: HttpSignatureVerifier,
|
private val httpSignatureVerifier: HttpSignatureVerifier,
|
||||||
private val transaction: Transaction,
|
private val transaction: Transaction,
|
||||||
private val httpSignatureHeaderParser: SignatureHeaderParser
|
private val httpSignatureHeaderParser: SignatureHeaderParser,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) :
|
) :
|
||||||
AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> {
|
AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> {
|
||||||
override fun loadUserDetails(token: PreAuthenticatedAuthenticationToken): UserDetails = runBlocking {
|
override fun loadUserDetails(token: PreAuthenticatedAuthenticationToken): UserDetails = runBlocking {
|
||||||
|
@ -34,11 +33,7 @@ class HttpSignatureUserDetailsService(
|
||||||
|
|
||||||
val keyId = token.principal as String
|
val keyId = token.principal as String
|
||||||
val findByKeyId = transaction.transaction {
|
val findByKeyId = transaction.transaction {
|
||||||
try {
|
actorRepository.findByKeyId(keyId) ?: throw UsernameNotFoundException("keyId: $keyId not found.")
|
||||||
actorQueryService.findByKeyId(keyId)
|
|
||||||
} catch (e: FailedToGetResourcesException) {
|
|
||||||
throw UsernameNotFoundException("User not found", e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val signature = httpSignatureHeaderParser.parse(credentials.headers)
|
val signature = httpSignatureHeaderParser.parse(credentials.headers)
|
||||||
|
|
|
@ -2,9 +2,9 @@ package dev.usbharu.hideout.core.infrastructure.springframework.oauth2
|
||||||
|
|
||||||
import dev.usbharu.hideout.application.config.ApplicationConfig
|
import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.springframework.security.core.userdetails.UserDetails
|
import org.springframework.security.core.userdetails.UserDetails
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService
|
import org.springframework.security.core.userdetails.UserDetailsService
|
||||||
|
@ -13,10 +13,10 @@ import org.springframework.stereotype.Service
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class UserDetailsServiceImpl(
|
class UserDetailsServiceImpl(
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val applicationConfig: ApplicationConfig,
|
private val applicationConfig: ApplicationConfig,
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
private val transaction: Transaction
|
private val transaction: Transaction,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) :
|
) :
|
||||||
UserDetailsService {
|
UserDetailsService {
|
||||||
override fun loadUserByUsername(username: String?): UserDetails = runBlocking {
|
override fun loadUserByUsername(username: String?): UserDetails = runBlocking {
|
||||||
|
@ -24,11 +24,10 @@ class UserDetailsServiceImpl(
|
||||||
throw UsernameNotFoundException("$username not found")
|
throw UsernameNotFoundException("$username not found")
|
||||||
}
|
}
|
||||||
transaction.transaction {
|
transaction.transaction {
|
||||||
val findById = try {
|
val findById =
|
||||||
actorQueryService.findByNameAndDomain(username, applicationConfig.url.host)
|
actorRepository.findByNameAndDomain(username, applicationConfig.url.host)
|
||||||
} catch (e: FailedToGetResourcesException) {
|
?: throw UserNotFoundException.withNameAndDomain(username, applicationConfig.url.host)
|
||||||
throw UsernameNotFoundException("$username not found", e)
|
|
||||||
}
|
|
||||||
val userDetails = userDetailRepository.findByActorId(findById.id)
|
val userDetails = userDetailRepository.findByActorId(findById.id)
|
||||||
?: throw UsernameNotFoundException("${findById.id} not found.")
|
?: throw UsernameNotFoundException("${findById.id} not found.")
|
||||||
UserDetailsImpl(
|
UserDetailsImpl(
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package dev.usbharu.hideout.core.query
|
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
|
||||||
import org.springframework.stereotype.Repository
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
interface ActorQueryService {
|
|
||||||
suspend fun findAll(limit: Int, offset: Long): List<Actor>
|
|
||||||
suspend fun findById(id: Long): Actor
|
|
||||||
suspend fun findByName(name: String): List<Actor>
|
|
||||||
suspend fun findByNameAndDomain(name: String, domain: String): Actor
|
|
||||||
suspend fun findByUrl(url: String): Actor
|
|
||||||
suspend fun findByIds(ids: List<Long>): List<Actor>
|
|
||||||
suspend fun existByNameAndDomain(name: String, domain: String): Boolean
|
|
||||||
suspend fun findByKeyId(keyId: String): Actor
|
|
||||||
}
|
|
|
@ -6,12 +6,11 @@ import dev.usbharu.hideout.activitypub.service.activity.follow.APSendFollowServi
|
||||||
import dev.usbharu.hideout.activitypub.service.activity.reject.ApSendRejectService
|
import dev.usbharu.hideout.activitypub.service.activity.reject.ApSendRejectService
|
||||||
import dev.usbharu.hideout.activitypub.service.activity.undo.APSendUndoService
|
import dev.usbharu.hideout.activitypub.service.activity.undo.APSendUndoService
|
||||||
import dev.usbharu.hideout.application.config.ApplicationConfig
|
import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
||||||
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.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.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.service.follow.SendFollowDto
|
import dev.usbharu.hideout.core.service.follow.SendFollowDto
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -19,7 +18,6 @@ import org.springframework.stereotype.Service
|
||||||
@Service
|
@Service
|
||||||
class RelationshipServiceImpl(
|
class RelationshipServiceImpl(
|
||||||
private val applicationConfig: ApplicationConfig,
|
private val applicationConfig: ApplicationConfig,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val relationshipRepository: RelationshipRepository,
|
private val relationshipRepository: RelationshipRepository,
|
||||||
private val apSendFollowService: APSendFollowService,
|
private val apSendFollowService: APSendFollowService,
|
||||||
private val apSendBlockService: APSendBlockService,
|
private val apSendBlockService: APSendBlockService,
|
||||||
|
@ -78,10 +76,10 @@ class RelationshipServiceImpl(
|
||||||
val remoteUser = isRemoteUser(targetId)
|
val remoteUser = isRemoteUser(targetId)
|
||||||
|
|
||||||
if (remoteUser != null) {
|
if (remoteUser != null) {
|
||||||
val user = actorQueryService.findById(actorId)
|
val user = actorRepository.findById(actorId) ?: throw UserNotFoundException.withId(actorId)
|
||||||
apSendFollowService.sendFollow(SendFollowDto(user, remoteUser))
|
apSendFollowService.sendFollow(SendFollowDto(user, remoteUser))
|
||||||
} else {
|
} else {
|
||||||
val target = actorQueryService.findById(targetId)
|
val target = actorRepository.findById(targetId) ?: throw UserNotFoundException.withId(targetId)
|
||||||
if (target.locked.not()) {
|
if (target.locked.not()) {
|
||||||
acceptFollowRequest(targetId, actorId)
|
acceptFollowRequest(targetId, actorId)
|
||||||
}
|
}
|
||||||
|
@ -93,8 +91,8 @@ class RelationshipServiceImpl(
|
||||||
override suspend fun block(actorId: Long, targetId: Long) {
|
override suspend fun block(actorId: Long, targetId: Long) {
|
||||||
val relationship = relationshipRepository.findByUserIdAndTargetUserId(actorId, targetId)
|
val relationship = relationshipRepository.findByUserIdAndTargetUserId(actorId, targetId)
|
||||||
|
|
||||||
val user = actorQueryService.findById(actorId)
|
val user = actorRepository.findById(actorId) ?: throw UserNotFoundException.withId(actorId)
|
||||||
val targetActor = actorQueryService.findById(targetId)
|
val targetActor = actorRepository.findById(targetId) ?: throw UserNotFoundException.withId(targetId)
|
||||||
if (relationship?.following == true) {
|
if (relationship?.following == true) {
|
||||||
actorRepository.save(user.decrementFollowing())
|
actorRepository.save(user.decrementFollowing())
|
||||||
actorRepository.save(targetActor.decrementFollowers())
|
actorRepository.save(targetActor.decrementFollowers())
|
||||||
|
@ -174,13 +172,13 @@ class RelationshipServiceImpl(
|
||||||
|
|
||||||
val copy = relationship.copy(followRequest = false, following = true, blocking = false)
|
val copy = relationship.copy(followRequest = false, following = true, blocking = false)
|
||||||
|
|
||||||
val user = actorQueryService.findById(actorId)
|
val user = actorRepository.findById(actorId) ?: throw UserNotFoundException.withId(actorId)
|
||||||
|
|
||||||
actorRepository.save(user.incrementFollowers())
|
actorRepository.save(user.incrementFollowers())
|
||||||
|
|
||||||
relationshipRepository.save(copy)
|
relationshipRepository.save(copy)
|
||||||
|
|
||||||
val remoteActor = actorQueryService.findById(targetId)
|
val remoteActor = actorRepository.findById(targetId) ?: throw UserNotFoundException.withId(targetId)
|
||||||
|
|
||||||
actorRepository.save(remoteActor.incrementFollowing())
|
actorRepository.save(remoteActor.incrementFollowing())
|
||||||
|
|
||||||
|
@ -209,7 +207,7 @@ class RelationshipServiceImpl(
|
||||||
val remoteUser = isRemoteUser(targetId)
|
val remoteUser = isRemoteUser(targetId)
|
||||||
|
|
||||||
if (remoteUser != null) {
|
if (remoteUser != null) {
|
||||||
val user = actorQueryService.findById(actorId)
|
val user = actorRepository.findById(actorId) ?: throw UserNotFoundException.withId(actorId)
|
||||||
apSendRejectService.sendRejectFollow(user, remoteUser)
|
apSendRejectService.sendRejectFollow(user, remoteUser)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,8 +236,8 @@ class RelationshipServiceImpl(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val user = actorQueryService.findById(actorId)
|
val user = actorRepository.findById(actorId) ?: throw UserNotFoundException.withId(actorId)
|
||||||
val targetActor = actorQueryService.findById(targetId)
|
val targetActor = actorRepository.findById(targetId) ?: throw UserNotFoundException.withId(targetId)
|
||||||
|
|
||||||
if (relationship.following) {
|
if (relationship.following) {
|
||||||
actorRepository.save(user.decrementFollowing())
|
actorRepository.save(user.decrementFollowing())
|
||||||
|
@ -280,7 +278,7 @@ class RelationshipServiceImpl(
|
||||||
|
|
||||||
val remoteUser = isRemoteUser(targetId)
|
val remoteUser = isRemoteUser(targetId)
|
||||||
if (remoteUser != null) {
|
if (remoteUser != null) {
|
||||||
val user = actorQueryService.findById(actorId)
|
val user = actorRepository.findById(actorId) ?: throw UserNotFoundException.withId(actorId)
|
||||||
apSendUndoService.sendUndoBlock(user, remoteUser)
|
apSendUndoService.sendUndoBlock(user, remoteUser)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,12 +313,8 @@ class RelationshipServiceImpl(
|
||||||
|
|
||||||
private suspend fun isRemoteUser(userId: Long): Actor? {
|
private suspend fun isRemoteUser(userId: Long): Actor? {
|
||||||
logger.trace("isRemoteUser({})", userId)
|
logger.trace("isRemoteUser({})", userId)
|
||||||
val user = try {
|
val user =
|
||||||
actorQueryService.findById(userId)
|
actorRepository.findById(userId) ?: throw UserNotFoundException.withId(userId)
|
||||||
} catch (e: FailedToGetResourcesException) {
|
|
||||||
logger.warn("User not found.", e)
|
|
||||||
throw IllegalStateException("User not found.", e)
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("user info {}", user)
|
logger.trace("user info {}", user)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package dev.usbharu.hideout.core.service.timeline
|
package dev.usbharu.hideout.core.service.timeline
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.post.Post
|
import dev.usbharu.hideout.core.domain.model.post.Post
|
||||||
import dev.usbharu.hideout.core.domain.model.post.Visibility
|
import dev.usbharu.hideout.core.domain.model.post.Visibility
|
||||||
import dev.usbharu.hideout.core.domain.model.timeline.Timeline
|
import dev.usbharu.hideout.core.domain.model.timeline.Timeline
|
||||||
import dev.usbharu.hideout.core.domain.model.timeline.TimelineRepository
|
import dev.usbharu.hideout.core.domain.model.timeline.TimelineRepository
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.query.FollowerQueryService
|
import dev.usbharu.hideout.core.query.FollowerQueryService
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -12,14 +13,14 @@ import org.springframework.stereotype.Service
|
||||||
@Service
|
@Service
|
||||||
class TimelineService(
|
class TimelineService(
|
||||||
private val followerQueryService: FollowerQueryService,
|
private val followerQueryService: FollowerQueryService,
|
||||||
private val actorQueryService: ActorQueryService,
|
private val timelineRepository: TimelineRepository,
|
||||||
private val timelineRepository: TimelineRepository
|
private val actorRepository: ActorRepository
|
||||||
) {
|
) {
|
||||||
suspend fun publishTimeline(post: Post, isLocal: Boolean) {
|
suspend fun publishTimeline(post: Post, isLocal: Boolean) {
|
||||||
val findFollowersById = followerQueryService.findFollowersById(post.actorId).toMutableList()
|
val findFollowersById = followerQueryService.findFollowersById(post.actorId).toMutableList()
|
||||||
if (isLocal) {
|
if (isLocal) {
|
||||||
// 自分自身も含める必要がある
|
// 自分自身も含める必要がある
|
||||||
val user = actorQueryService.findById(post.actorId)
|
val user = actorRepository.findById(post.actorId) ?: throw UserNotFoundException.withId(post.actorId)
|
||||||
findFollowersById.add(user)
|
findFollowersById.add(user)
|
||||||
}
|
}
|
||||||
val timelines = findFollowersById.map {
|
val timelines = findFollowersById.map {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package dev.usbharu.hideout.core.service.user
|
package dev.usbharu.hideout.core.service.user
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.security.*
|
import java.security.*
|
||||||
|
@ -8,13 +9,14 @@ import java.util.*
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class UserAuthServiceImpl(
|
class UserAuthServiceImpl(
|
||||||
val actorQueryService: ActorQueryService
|
private val actorRepository: ActorRepository,
|
||||||
|
private val applicationConfig: ApplicationConfig
|
||||||
) : UserAuthService {
|
) : UserAuthService {
|
||||||
|
|
||||||
override fun hash(password: String): String = BCryptPasswordEncoder().encode(password)
|
override fun hash(password: String): String = BCryptPasswordEncoder().encode(password)
|
||||||
|
|
||||||
override suspend fun usernameAlreadyUse(username: String): Boolean {
|
override suspend fun usernameAlreadyUse(username: String): Boolean {
|
||||||
actorQueryService.findByName(username)
|
actorRepository.findByNameAndDomain(username, applicationConfig.url.host) ?: return false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package dev.usbharu.hideout.core.service.user
|
||||||
import dev.usbharu.hideout.activitypub.service.activity.delete.APSendDeleteService
|
import dev.usbharu.hideout.activitypub.service.activity.delete.APSendDeleteService
|
||||||
import dev.usbharu.hideout.application.config.ApplicationConfig
|
import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
||||||
|
import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
||||||
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.deletedActor.DeletedActor
|
import dev.usbharu.hideout.core.domain.model.deletedActor.DeletedActor
|
||||||
|
@ -11,7 +12,6 @@ import dev.usbharu.hideout.core.domain.model.reaction.ReactionRepository
|
||||||
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.userdetails.UserDetail
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetail
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.query.DeletedActorQueryService
|
import dev.usbharu.hideout.core.query.DeletedActorQueryService
|
||||||
import dev.usbharu.hideout.core.service.instance.InstanceService
|
import dev.usbharu.hideout.core.service.instance.InstanceService
|
||||||
import dev.usbharu.hideout.core.service.post.PostService
|
import dev.usbharu.hideout.core.service.post.PostService
|
||||||
|
@ -26,7 +26,6 @@ import java.time.Instant
|
||||||
class UserServiceImpl(
|
class UserServiceImpl(
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
private val userAuthService: UserAuthService,
|
private val userAuthService: UserAuthService,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val actorBuilder: Actor.UserBuilder,
|
private val actorBuilder: Actor.UserBuilder,
|
||||||
private val applicationConfig: ApplicationConfig,
|
private val applicationConfig: ApplicationConfig,
|
||||||
private val instanceService: InstanceService,
|
private val instanceService: InstanceService,
|
||||||
|
@ -42,7 +41,7 @@ class UserServiceImpl(
|
||||||
UserService {
|
UserService {
|
||||||
|
|
||||||
override suspend fun usernameAlreadyUse(username: String): Boolean {
|
override suspend fun usernameAlreadyUse(username: String): Boolean {
|
||||||
val findByNameAndDomain = actorQueryService.findByNameAndDomain(username, applicationConfig.url.host)
|
val findByNameAndDomain = actorRepository.findByNameAndDomain(username, applicationConfig.url.host)
|
||||||
return findByNameAndDomain != null
|
return findByNameAndDomain != null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +115,7 @@ class UserServiceImpl(
|
||||||
save
|
save
|
||||||
} catch (_: ExposedSQLException) {
|
} catch (_: ExposedSQLException) {
|
||||||
logger.warn("FAILED User already exists. name: {} url: {}", user.name, user.url)
|
logger.warn("FAILED User already exists. name: {} url: {}", user.name, user.url)
|
||||||
actorQueryService.findByUrl(user.url)
|
actorRepository.findByUrl(user.url)!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +141,7 @@ class UserServiceImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun deleteRemoteActor(actorId: Long) {
|
override suspend fun deleteRemoteActor(actorId: Long) {
|
||||||
val actor = actorQueryService.findById(actorId)
|
val actor = actorRepository.findByIdWithLock(actorId) ?: throw UserNotFoundException.withId(actorId)
|
||||||
val deletedActor = DeletedActor(
|
val deletedActor = DeletedActor(
|
||||||
actor.id,
|
actor.id,
|
||||||
actor.name,
|
actor.name,
|
||||||
|
@ -161,7 +160,7 @@ class UserServiceImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun deleteLocalUser(userId: Long) {
|
override suspend fun deleteLocalUser(userId: Long) {
|
||||||
val actor = actorQueryService.findById(userId)
|
val actor = actorRepository.findByIdWithLock(userId) ?: throw UserNotFoundException.withId(userId)
|
||||||
apSendDeleteService.sendDeleteActor(actor)
|
apSendDeleteService.sendDeleteActor(actor)
|
||||||
val deletedActor = DeletedActor(
|
val deletedActor = DeletedActor(
|
||||||
actor.id,
|
actor.id,
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package dev.usbharu.hideout.mastodon.service.status
|
package dev.usbharu.hideout.mastodon.service.status
|
||||||
|
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
import dev.usbharu.hideout.application.external.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.media.MediaRepository
|
import dev.usbharu.hideout.core.domain.model.media.MediaRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.media.toMediaAttachments
|
import dev.usbharu.hideout.core.domain.model.media.toMediaAttachments
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.query.PostQueryService
|
import dev.usbharu.hideout.core.query.PostQueryService
|
||||||
import dev.usbharu.hideout.core.service.post.PostCreateDto
|
import dev.usbharu.hideout.core.service.post.PostCreateDto
|
||||||
import dev.usbharu.hideout.core.service.post.PostService
|
import dev.usbharu.hideout.core.service.post.PostService
|
||||||
|
@ -30,9 +29,9 @@ class StatsesApiServiceImpl(
|
||||||
private val postService: PostService,
|
private val postService: PostService,
|
||||||
private val accountService: AccountService,
|
private val accountService: AccountService,
|
||||||
private val postQueryService: PostQueryService,
|
private val postQueryService: PostQueryService,
|
||||||
private val actorQueryService: ActorQueryService,
|
|
||||||
private val mediaRepository: MediaRepository,
|
private val mediaRepository: MediaRepository,
|
||||||
private val transaction: Transaction
|
private val transaction: Transaction,
|
||||||
|
private val actorRepository: ActorRepository
|
||||||
) :
|
) :
|
||||||
StatusesApiService {
|
StatusesApiService {
|
||||||
override suspend fun postStatus(
|
override suspend fun postStatus(
|
||||||
|
@ -54,11 +53,7 @@ class StatsesApiServiceImpl(
|
||||||
val account = accountService.findById(userId)
|
val account = accountService.findById(userId)
|
||||||
|
|
||||||
val replyUser = if (post.replyId != null) {
|
val replyUser = if (post.replyId != null) {
|
||||||
try {
|
actorRepository.findById(postQueryService.findById(post.replyId).actorId)?.id
|
||||||
actorQueryService.findById(postQueryService.findById(post.replyId).actorId).id
|
|
||||||
} catch (ignore: FailedToGetResourcesException) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
hideout:
|
hideout:
|
||||||
url: "https://test-hideout.usbharu.dev"
|
url: "https://test-hideout.usbharu.dev"
|
||||||
use-mongodb: false
|
use-mongodb: true
|
||||||
security:
|
security:
|
||||||
jwt:
|
jwt:
|
||||||
generate: true
|
generate: true
|
||||||
|
@ -22,14 +22,14 @@ spring:
|
||||||
url: "jdbc:postgresql:hideout2"
|
url: "jdbc:postgresql:hideout2"
|
||||||
username: "postgres"
|
username: "postgres"
|
||||||
password: ""
|
password: ""
|
||||||
# data:
|
data:
|
||||||
# mongodb:
|
mongodb:
|
||||||
# auto-index-creation: true
|
auto-index-creation: true
|
||||||
# host: localhost
|
host: localhost
|
||||||
# port: 27017
|
port: 27017
|
||||||
# database: hideout
|
database: hideout
|
||||||
# username: hideoutuser
|
# username: hideoutuser
|
||||||
# password: hideoutpass
|
# password: hideoutpass
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 40MB
|
max-file-size: 40MB
|
||||||
|
|
|
@ -1,4 +1,18 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>logFile.log</file>
|
||||||
|
<encoder>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%X{x-request-id}] %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- daily rollover -->
|
||||||
|
<fileNamePattern>logFile.%d{yyyy-MM-dd_HH}.log</fileNamePattern>
|
||||||
|
|
||||||
|
<!-- keep 30 days worth of history -->
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
</appender>
|
||||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%X{x-request-id}] [%X{x-job-id}] %logger{36} -
|
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%X{x-request-id}] [%X{x-job-id}] %logger{36} -
|
||||||
|
@ -8,6 +22,7 @@
|
||||||
</appender>
|
</appender>
|
||||||
<root level="DEBUG">
|
<root level="DEBUG">
|
||||||
<appender-ref ref="STDOUT"/>
|
<appender-ref ref="STDOUT"/>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
</root>
|
</root>
|
||||||
<logger name="org.eclipse.jetty" level="INFO"/>
|
<logger name="org.eclipse.jetty" level="INFO"/>
|
||||||
<logger name="io.netty" level="INFO"/>
|
<logger name="io.netty" level="INFO"/>
|
||||||
|
|
|
@ -5,7 +5,6 @@ import dev.usbharu.hideout.activitypub.domain.model.Follow
|
||||||
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
import dev.usbharu.hideout.activitypub.service.common.APRequestService
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverAcceptJob
|
import dev.usbharu.hideout.core.external.job.DeliverAcceptJob
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverAcceptJobParam
|
import dev.usbharu.hideout.core.external.job.DeliverAcceptJobParam
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
|
@ -7,7 +7,6 @@ import dev.usbharu.hideout.activitypub.domain.model.Like
|
||||||
import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext
|
import dev.usbharu.hideout.activitypub.service.common.ActivityPubProcessContext
|
||||||
import dev.usbharu.hideout.activitypub.service.common.ActivityType
|
import dev.usbharu.hideout.activitypub.service.common.ActivityType
|
||||||
import dev.usbharu.hideout.application.config.ActivityPubConfig
|
import dev.usbharu.hideout.application.config.ActivityPubConfig
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
import dev.usbharu.hideout.core.service.relationship.RelationshipService
|
||||||
import dev.usbharu.httpsignature.common.HttpHeaders
|
import dev.usbharu.httpsignature.common.HttpHeaders
|
||||||
import dev.usbharu.httpsignature.common.HttpMethod
|
import dev.usbharu.httpsignature.common.HttpMethod
|
||||||
|
|
|
@ -7,7 +7,6 @@ import dev.usbharu.hideout.activitypub.service.objects.note.APNoteServiceImpl
|
||||||
import dev.usbharu.hideout.application.config.ActivityPubConfig
|
import dev.usbharu.hideout.application.config.ActivityPubConfig
|
||||||
import dev.usbharu.hideout.application.config.ApplicationConfig
|
import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
import dev.usbharu.hideout.core.external.job.DeliverPostJob
|
import dev.usbharu.hideout.core.external.job.DeliverPostJob
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.query.FollowerQueryService
|
import dev.usbharu.hideout.core.query.FollowerQueryService
|
||||||
import dev.usbharu.hideout.core.service.job.JobQueueParentService
|
import dev.usbharu.hideout.core.service.job.JobQueueParentService
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
|
|
|
@ -16,7 +16,6 @@ import dev.usbharu.hideout.application.service.id.TwitterSnowflakeIdGenerateServ
|
||||||
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
import dev.usbharu.hideout.core.domain.exception.FailedToGetResourcesException
|
||||||
import dev.usbharu.hideout.core.domain.model.post.Post
|
import dev.usbharu.hideout.core.domain.model.post.Post
|
||||||
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.query.PostQueryService
|
import dev.usbharu.hideout.core.query.PostQueryService
|
||||||
import dev.usbharu.hideout.core.service.post.PostService
|
import dev.usbharu.hideout.core.service.post.PostService
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
|
|
|
@ -9,7 +9,6 @@ import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
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.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.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.service.follow.SendFollowDto
|
import dev.usbharu.hideout.core.service.follow.SendFollowDto
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
|
@ -5,7 +5,6 @@ import dev.usbharu.hideout.core.domain.model.actor.Actor
|
||||||
import dev.usbharu.hideout.core.domain.model.post.Visibility
|
import dev.usbharu.hideout.core.domain.model.post.Visibility
|
||||||
import dev.usbharu.hideout.core.domain.model.timeline.Timeline
|
import dev.usbharu.hideout.core.domain.model.timeline.Timeline
|
||||||
import dev.usbharu.hideout.core.domain.model.timeline.TimelineRepository
|
import dev.usbharu.hideout.core.domain.model.timeline.TimelineRepository
|
||||||
import dev.usbharu.hideout.core.query.ActorQueryService
|
|
||||||
import dev.usbharu.hideout.core.query.FollowerQueryService
|
import dev.usbharu.hideout.core.query.FollowerQueryService
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
|
|
|
@ -38,7 +38,6 @@ class ActorServiceTest {
|
||||||
UserServiceImpl(
|
UserServiceImpl(
|
||||||
actorRepository = actorRepository,
|
actorRepository = actorRepository,
|
||||||
userAuthService = userAuthService,
|
userAuthService = userAuthService,
|
||||||
actorQueryService = mock(),
|
|
||||||
actorBuilder = actorBuilder,
|
actorBuilder = actorBuilder,
|
||||||
applicationConfig = testApplicationConfig,
|
applicationConfig = testApplicationConfig,
|
||||||
instanceService = mock(),
|
instanceService = mock(),
|
||||||
|
@ -85,7 +84,6 @@ class ActorServiceTest {
|
||||||
UserServiceImpl(
|
UserServiceImpl(
|
||||||
actorRepository = actorRepository,
|
actorRepository = actorRepository,
|
||||||
userAuthService = mock(),
|
userAuthService = mock(),
|
||||||
actorQueryService = mock(),
|
|
||||||
actorBuilder = actorBuilder,
|
actorBuilder = actorBuilder,
|
||||||
applicationConfig = testApplicationConfig,
|
applicationConfig = testApplicationConfig,
|
||||||
instanceService = mock(),
|
instanceService = mock(),
|
||||||
|
|
Loading…
Reference in New Issue