mirror of https://github.com/usbharu/Hideout.git
commit
716bf190b5
|
@ -17,10 +17,11 @@
|
||||||
package dev.usbharu.hideout.core.application.actor
|
package dev.usbharu.hideout.core.application.actor
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
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.emoji.CustomEmojiRepository
|
import dev.usbharu.hideout.core.domain.model.emoji.CustomEmojiRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -33,8 +34,8 @@ class GetUserDetailApplicationService(
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<GetUserDetail, UserDetail>(transaction, Companion.logger) {
|
AbstractApplicationService<GetUserDetail, UserDetail>(transaction, Companion.logger) {
|
||||||
override suspend fun internalExecute(command: GetUserDetail, executor: CommandExecutor): UserDetail {
|
override suspend fun internalExecute(command: GetUserDetail, principal: Principal): UserDetail {
|
||||||
val userDetail = userDetailRepository.findById(command.id)
|
val userDetail = userDetailRepository.findById(UserDetailId(command.id))
|
||||||
?: throw IllegalArgumentException("actor does not exist")
|
?: throw IllegalArgumentException("actor does not exist")
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
package dev.usbharu.hideout.core.application.actor
|
package dev.usbharu.hideout.core.application.actor
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.config.ApplicationConfig
|
import dev.usbharu.hideout.core.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.instance.InstanceRepository
|
import dev.usbharu.hideout.core.domain.model.instance.InstanceRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
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.UserDetailId
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
|
@ -46,7 +46,7 @@ class RegisterLocalActorApplicationService(
|
||||||
private val idGenerateService: IdGenerateService,
|
private val idGenerateService: IdGenerateService,
|
||||||
) : AbstractApplicationService<RegisterLocalActor, URI>(transaction, Companion.logger) {
|
) : AbstractApplicationService<RegisterLocalActor, URI>(transaction, Companion.logger) {
|
||||||
|
|
||||||
override suspend fun internalExecute(command: RegisterLocalActor, executor: CommandExecutor): URI {
|
override suspend fun internalExecute(command: RegisterLocalActor, principal: Principal): URI {
|
||||||
if (actorDomainService.usernameAlreadyUse(command.name)) {
|
if (actorDomainService.usernameAlreadyUse(command.name)) {
|
||||||
// todo 適切な例外を考える
|
// todo 適切な例外を考える
|
||||||
throw Exception("Username already exists")
|
throw Exception("Username already exists")
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package dev.usbharu.hideout.core.application.domainevent.subscribers
|
package dev.usbharu.hideout.core.application.domainevent.subscribers
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.DomainEventCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.timeline.AddTimelineRelationship
|
import dev.usbharu.hideout.core.application.timeline.AddTimelineRelationship
|
||||||
import dev.usbharu.hideout.core.application.timeline.UserAddTimelineRelationshipApplicationService
|
import dev.usbharu.hideout.core.application.timeline.UserAddTimelineRelationshipApplicationService
|
||||||
import dev.usbharu.hideout.core.domain.event.relationship.RelationshipEvent
|
import dev.usbharu.hideout.core.domain.event.relationship.RelationshipEvent
|
||||||
|
@ -38,12 +36,7 @@ class TimelineRelationshipFollowSubscriber(
|
||||||
relationship.targetActorId,
|
relationship.targetActorId,
|
||||||
Visible.FOLLOWERS
|
Visible.FOLLOWERS
|
||||||
)
|
)
|
||||||
), DomainEventCommandExecutor("", object : UserDetailGettableCommandExecutor {
|
), it.body.principal
|
||||||
override val userDetailId: Long
|
|
||||||
get() = userDetail.id.id
|
|
||||||
override val executor: String
|
|
||||||
get() = userDetail.id.id.toString()
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,12 @@ package dev.usbharu.hideout.core.application.filter
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterAction
|
import dev.usbharu.hideout.core.domain.model.filter.FilterAction
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterContext
|
import dev.usbharu.hideout.core.domain.model.filter.FilterContext
|
||||||
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
data class RegisterFilter(
|
data class RegisterFilter(
|
||||||
val filterName: String,
|
val filterName: String,
|
||||||
val filterContext: Set<FilterContext>,
|
val filterContext: Set<FilterContext>,
|
||||||
val filterAction: FilterAction,
|
val filterAction: FilterAction,
|
||||||
val filterKeywords: Set<RegisterFilterKeyword>,
|
val filterKeywords: Set<RegisterFilterKeyword>,
|
||||||
|
val userDetailId: UserDetailId
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
package dev.usbharu.hideout.core.application.filter
|
package dev.usbharu.hideout.core.application.filter
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterId
|
import dev.usbharu.hideout.core.domain.model.filter.FilterId
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterRepository
|
import dev.usbharu.hideout.core.domain.model.filter.FilterRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class UserDeleteFilterApplicationService(private val filterRepository: FilterRep
|
||||||
transaction,
|
transaction,
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
override suspend fun internalExecute(command: DeleteFilter, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: DeleteFilter, principal: Principal) {
|
||||||
val filter = filterRepository.findByFilterId(FilterId(command.filterId)) ?: throw Exception("not found")
|
val filter = filterRepository.findByFilterId(FilterId(command.filterId)) ?: throw Exception("not found")
|
||||||
filterRepository.delete(filter)
|
filterRepository.delete(filter)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
package dev.usbharu.hideout.core.application.filter
|
package dev.usbharu.hideout.core.application.filter
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterId
|
import dev.usbharu.hideout.core.domain.model.filter.FilterId
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterRepository
|
import dev.usbharu.hideout.core.domain.model.filter.FilterRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class UserGetFilterApplicationService(private val filterRepository: FilterReposi
|
||||||
transaction,
|
transaction,
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
override suspend fun internalExecute(command: GetFilter, executor: CommandExecutor): Filter {
|
override suspend fun internalExecute(command: GetFilter, principal: Principal): Filter {
|
||||||
val filter = filterRepository.findByFilterId(FilterId(command.filterId)) ?: throw Exception("Not Found")
|
val filter = filterRepository.findByFilterId(FilterId(command.filterId)) ?: throw Exception("Not Found")
|
||||||
|
|
||||||
return Filter.of(filter)
|
return Filter.of(filter)
|
||||||
|
|
|
@ -17,12 +17,10 @@
|
||||||
package dev.usbharu.hideout.core.application.filter
|
package dev.usbharu.hideout.core.application.filter
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.*
|
import dev.usbharu.hideout.core.domain.model.filter.*
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterKeyword
|
import dev.usbharu.hideout.core.domain.model.filter.FilterKeyword
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService
|
import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -38,12 +36,11 @@ class UserRegisterFilterApplicationService(
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override suspend fun internalExecute(command: RegisterFilter, executor: CommandExecutor): Filter {
|
override suspend fun internalExecute(command: RegisterFilter, principal: Principal): Filter {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
|
||||||
|
|
||||||
val filter = dev.usbharu.hideout.core.domain.model.filter.Filter.create(
|
val filter = dev.usbharu.hideout.core.domain.model.filter.Filter.create(
|
||||||
id = FilterId(idGenerateService.generateId()),
|
id = FilterId(idGenerateService.generateId()),
|
||||||
userDetailId = UserDetailId(executor.userDetailId),
|
userDetailId = command.userDetailId,
|
||||||
name = FilterName(command.filterName),
|
name = FilterName(command.filterName),
|
||||||
filterContext = command.filterContext,
|
filterContext = command.filterContext,
|
||||||
filterAction = command.filterAction,
|
filterAction = command.filterAction,
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
package dev.usbharu.hideout.core.application.media
|
package dev.usbharu.hideout.core.application.media
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.model.media.*
|
import dev.usbharu.hideout.core.domain.model.media.*
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService
|
import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService
|
||||||
import dev.usbharu.hideout.core.external.media.MediaProcessor
|
import dev.usbharu.hideout.core.external.media.MediaProcessor
|
||||||
import dev.usbharu.hideout.core.external.mediastore.MediaStore
|
import dev.usbharu.hideout.core.external.mediastore.MediaStore
|
||||||
|
@ -39,7 +39,7 @@ class UploadMediaApplicationService(
|
||||||
transaction,
|
transaction,
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
override suspend fun internalExecute(command: UploadMedia, executor: CommandExecutor): Media {
|
override suspend fun internalExecute(command: UploadMedia, principal: Principal): Media {
|
||||||
val process = mediaProcessor.process(command.path, command.name, null)
|
val process = mediaProcessor.process(command.path, command.name, null)
|
||||||
val id = idGenerateService.generateId()
|
val id = idGenerateService.generateId()
|
||||||
val thumbnailUri = if (process.thumbnailPath != null) {
|
val thumbnailUri = if (process.thumbnailPath != null) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ package dev.usbharu.hideout.core.application.post
|
||||||
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.post.PostId
|
import dev.usbharu.hideout.core.domain.model.post.PostId
|
||||||
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ class DeleteLocalPostApplicationService(
|
||||||
) {
|
) {
|
||||||
suspend fun delete(postId: Long, userDetailId: Long) {
|
suspend fun delete(postId: Long, userDetailId: Long) {
|
||||||
val findById = postRepository.findById(PostId(postId))!!
|
val findById = postRepository.findById(PostId(postId))!!
|
||||||
val user = userDetailRepository.findById(userDetailId)!!
|
val user = userDetailRepository.findById(UserDetailId(userDetailId))!!
|
||||||
val actor = actorRepository.findById(user.actorId)!!
|
val actor = actorRepository.findById(user.actorId)!!
|
||||||
findById.delete(actor)
|
findById.delete(actor)
|
||||||
postRepository.save(findById)
|
postRepository.save(findById)
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
package dev.usbharu.hideout.core.application.post
|
package dev.usbharu.hideout.core.application.post
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.model.post.PostId
|
import dev.usbharu.hideout.core.domain.model.post.PostId
|
||||||
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ import org.springframework.stereotype.Service
|
||||||
class GetPostApplicationService(private val postRepository: PostRepository, transaction: Transaction) :
|
class GetPostApplicationService(private val postRepository: PostRepository, transaction: Transaction) :
|
||||||
AbstractApplicationService<GetPost, Post>(transaction, logger) {
|
AbstractApplicationService<GetPost, Post>(transaction, logger) {
|
||||||
|
|
||||||
override suspend fun internalExecute(command: GetPost, executor: CommandExecutor): Post {
|
override suspend fun internalExecute(command: GetPost, principal: Principal): Post {
|
||||||
val post = postRepository.findById(PostId(command.postId)) ?: throw Exception("Post not found")
|
val post = postRepository.findById(PostId(command.postId)) ?: throw Exception("Post not found")
|
||||||
|
|
||||||
return Post.of(post)
|
return Post.of(post)
|
||||||
|
|
|
@ -17,13 +17,14 @@
|
||||||
package dev.usbharu.hideout.core.application.post
|
package dev.usbharu.hideout.core.application.post
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
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.media.MediaId
|
import dev.usbharu.hideout.core.domain.model.media.MediaId
|
||||||
import dev.usbharu.hideout.core.domain.model.post.PostId
|
import dev.usbharu.hideout.core.domain.model.post.PostId
|
||||||
import dev.usbharu.hideout.core.domain.model.post.PostOverview
|
import dev.usbharu.hideout.core.domain.model.post.PostOverview
|
||||||
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import dev.usbharu.hideout.core.infrastructure.factory.PostFactoryImpl
|
import dev.usbharu.hideout.core.infrastructure.factory.PostFactoryImpl
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
|
@ -39,9 +40,9 @@ class RegisterLocalPostApplicationService(
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
) : AbstractApplicationService<RegisterLocalPost, Long>(transaction, Companion.logger) {
|
) : AbstractApplicationService<RegisterLocalPost, Long>(transaction, Companion.logger) {
|
||||||
|
|
||||||
override suspend fun internalExecute(command: RegisterLocalPost, executor: CommandExecutor): Long {
|
override suspend fun internalExecute(command: RegisterLocalPost, principal: Principal): Long {
|
||||||
val actorId = (
|
val actorId = (
|
||||||
userDetailRepository.findById(command.userDetailId)
|
userDetailRepository.findById(UserDetailId(command.userDetailId))
|
||||||
?: throw IllegalStateException("actor not found")
|
?: throw IllegalStateException("actor not found")
|
||||||
).actorId
|
).actorId
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,13 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.post
|
package dev.usbharu.hideout.core.application.post
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
data class UpdateLocalNote(
|
data class UpdateLocalNote(
|
||||||
val postId: Long,
|
val postId: Long,
|
||||||
val overview: String?,
|
val overview: String?,
|
||||||
val content: String,
|
val content: String,
|
||||||
val sensitive: Boolean,
|
val sensitive: Boolean,
|
||||||
val mediaIds: List<Long>,
|
val mediaIds: List<Long>,
|
||||||
|
val userDetailId: UserDetailId
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
package dev.usbharu.hideout.core.application.post
|
package dev.usbharu.hideout.core.application.post
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
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.media.MediaId
|
import dev.usbharu.hideout.core.domain.model.media.MediaId
|
||||||
import dev.usbharu.hideout.core.domain.model.post.PostId
|
import dev.usbharu.hideout.core.domain.model.post.PostId
|
||||||
import dev.usbharu.hideout.core.domain.model.post.PostOverview
|
import dev.usbharu.hideout.core.domain.model.post.PostOverview
|
||||||
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import dev.usbharu.hideout.core.infrastructure.factory.PostContentFactoryImpl
|
import dev.usbharu.hideout.core.infrastructure.factory.PostContentFactoryImpl
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
@ -39,10 +38,9 @@ class UpdateLocalNoteApplicationService(
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
) : AbstractApplicationService<UpdateLocalNote, Unit>(transaction, logger) {
|
) : AbstractApplicationService<UpdateLocalNote, Unit>(transaction, logger) {
|
||||||
|
|
||||||
override suspend fun internalExecute(command: UpdateLocalNote, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: UpdateLocalNote, principal: Principal) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
|
||||||
|
|
||||||
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
val userDetail = userDetailRepository.findById(command.userDetailId)!!
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
val post = postRepository.findById(PostId(command.postId))!!
|
val post = postRepository.findById(PostId(command.postId))!!
|
||||||
|
|
||||||
|
|
|
@ -16,4 +16,6 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.acceptfollowrequest
|
package dev.usbharu.hideout.core.application.relationship.acceptfollowrequest
|
||||||
|
|
||||||
data class AcceptFollowRequest(val sourceActorId: Long)
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
|
data class AcceptFollowRequest(val sourceActorId: Long, val userDetailId: UserDetailId)
|
||||||
|
|
|
@ -18,12 +18,11 @@ package dev.usbharu.hideout.core.application.relationship.acceptfollowrequest
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -36,10 +35,9 @@ class UserAcceptFollowRequestApplicationService(
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<AcceptFollowRequest, Unit>(transaction, logger) {
|
AbstractApplicationService<AcceptFollowRequest, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: AcceptFollowRequest, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: AcceptFollowRequest, principal: Principal) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
|
||||||
|
|
||||||
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
val userDetail = userDetailRepository.findById(command.userDetailId)!!
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
|
|
||||||
val targetId = ActorId(command.sourceActorId)
|
val targetId = ActorId(command.sourceActorId)
|
||||||
|
|
|
@ -16,4 +16,6 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.block
|
package dev.usbharu.hideout.core.application.relationship.block
|
||||||
|
|
||||||
data class Block(val targetActorId: Long)
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
|
data class Block(val targetActorId: Long, val userDetailId: UserDetailId)
|
||||||
|
|
|
@ -17,13 +17,12 @@
|
||||||
package dev.usbharu.hideout.core.application.relationship.block
|
package dev.usbharu.hideout.core.application.relationship.block
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import dev.usbharu.hideout.core.domain.service.relationship.RelationshipDomainService
|
import dev.usbharu.hideout.core.domain.service.relationship.RelationshipDomainService
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
@ -38,10 +37,9 @@ class UserBlockApplicationService(
|
||||||
private val relationshipDomainService: RelationshipDomainService,
|
private val relationshipDomainService: RelationshipDomainService,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<Block, Unit>(transaction, logger) {
|
AbstractApplicationService<Block, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: Block, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: Block, principal: Principal) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
|
||||||
|
|
||||||
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
val userDetail = userDetailRepository.findById(command.userDetailId)!!
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
|
|
||||||
val targetId = ActorId(command.targetActorId)
|
val targetId = ActorId(command.targetActorId)
|
||||||
|
|
|
@ -16,4 +16,6 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.followrequest
|
package dev.usbharu.hideout.core.application.relationship.followrequest
|
||||||
|
|
||||||
data class FollowRequest(val targetActorId: Long)
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
|
data class FollowRequest(val targetActorId: Long, val userDetailId: UserDetailId)
|
||||||
|
|
|
@ -17,13 +17,12 @@
|
||||||
package dev.usbharu.hideout.core.application.relationship.followrequest
|
package dev.usbharu.hideout.core.application.relationship.followrequest
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -39,10 +38,9 @@ class UserFollowRequestApplicationService(
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override suspend fun internalExecute(command: FollowRequest, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: FollowRequest, principal: Principal) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
|
||||||
|
|
||||||
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
val userDetail = userDetailRepository.findById(command.userDetailId)!!
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
|
|
||||||
val targetId = ActorId(command.targetActorId)
|
val targetId = ActorId(command.targetActorId)
|
||||||
|
|
|
@ -16,4 +16,6 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.get
|
package dev.usbharu.hideout.core.application.relationship.get
|
||||||
|
|
||||||
data class GetRelationship(val targetActorId: Long)
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
|
data class GetRelationship(val targetActorId: Long, val userDetailId: UserDetailId)
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
package dev.usbharu.hideout.core.application.relationship.get
|
package dev.usbharu.hideout.core.application.relationship.get
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.actorinstancerelationship.ActorInstanceRelationship
|
import dev.usbharu.hideout.core.domain.model.actorinstancerelationship.ActorInstanceRelationship
|
||||||
import dev.usbharu.hideout.core.domain.model.actorinstancerelationship.ActorInstanceRelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.actorinstancerelationship.ActorInstanceRelationshipRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -41,9 +40,8 @@ class GetRelationshipApplicationService(
|
||||||
transaction,
|
transaction,
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
override suspend fun internalExecute(command: GetRelationship, executor: CommandExecutor): Relationship {
|
override suspend fun internalExecute(command: GetRelationship, principal: Principal): Relationship {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
val userDetail = userDetailRepository.findById(command.userDetailId)!!
|
||||||
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
val targetId = ActorId(command.targetActorId)
|
val targetId = ActorId(command.targetActorId)
|
||||||
val target = actorRepository.findById(targetId)!!
|
val target = actorRepository.findById(targetId)!!
|
||||||
|
|
|
@ -16,4 +16,6 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.mute
|
package dev.usbharu.hideout.core.application.relationship.mute
|
||||||
|
|
||||||
data class Mute(val targetActorId: Long)
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
|
data class Mute(val targetActorId: Long, val userDetailId: UserDetailId)
|
||||||
|
|
|
@ -18,13 +18,12 @@ package dev.usbharu.hideout.core.application.relationship.mute
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -37,10 +36,9 @@ class UserMuteApplicationService(
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<Mute, Unit>(transaction, logger) {
|
AbstractApplicationService<Mute, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: Mute, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: Mute, principal: Principal) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
|
||||||
|
|
||||||
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
val userDetail = userDetailRepository.findById(command.userDetailId)!!
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
|
|
||||||
val targetId = ActorId(command.targetActorId)
|
val targetId = ActorId(command.targetActorId)
|
||||||
|
|
|
@ -16,4 +16,6 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.rejectfollowrequest
|
package dev.usbharu.hideout.core.application.relationship.rejectfollowrequest
|
||||||
|
|
||||||
data class RejectFollowRequest(val sourceActorId: Long)
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
|
data class RejectFollowRequest(val sourceActorId: Long, val userDetailId: UserDetailId)
|
||||||
|
|
|
@ -18,12 +18,11 @@ package dev.usbharu.hideout.core.application.relationship.rejectfollowrequest
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -36,10 +35,9 @@ class UserRejectFollowRequestApplicationService(
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<RejectFollowRequest, Unit>(transaction, logger) {
|
AbstractApplicationService<RejectFollowRequest, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: RejectFollowRequest, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: RejectFollowRequest, principal: Principal) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
|
||||||
|
|
||||||
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
val userDetail = userDetailRepository.findById(command.userDetailId)!!
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
|
|
||||||
val targetId = ActorId(command.sourceActorId)
|
val targetId = ActorId(command.sourceActorId)
|
||||||
|
|
|
@ -16,4 +16,4 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.removefromfollowers
|
package dev.usbharu.hideout.core.application.relationship.removefromfollowers
|
||||||
|
|
||||||
data class RemoveFromFollowers(val targetActorId: Long)
|
data class RemoveFromFollowers(val targetActorId: Long, val userDetailId: Long)
|
||||||
|
|
|
@ -18,13 +18,13 @@ package dev.usbharu.hideout.core.application.relationship.removefromfollowers
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -37,10 +37,9 @@ class UserRemoveFromFollowersApplicationService(
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<RemoveFromFollowers, Unit>(transaction, logger) {
|
AbstractApplicationService<RemoveFromFollowers, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: RemoveFromFollowers, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: RemoveFromFollowers, principal: Principal) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
|
||||||
|
|
||||||
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
val userDetail = userDetailRepository.findById(UserDetailId(command.userDetailId))!!
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
|
|
||||||
val targetId = ActorId(command.targetActorId)
|
val targetId = ActorId(command.targetActorId)
|
||||||
|
|
|
@ -16,4 +16,6 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.unblock
|
package dev.usbharu.hideout.core.application.relationship.unblock
|
||||||
|
|
||||||
data class Unblock(val targetActorId: Long)
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
|
data class Unblock(val targetActorId: Long, val userDetailId: UserDetailId)
|
||||||
|
|
|
@ -18,13 +18,12 @@ package dev.usbharu.hideout.core.application.relationship.unblock
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -37,10 +36,9 @@ class UserUnblockApplicationService(
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<Unblock, Unit>(transaction, logger) {
|
AbstractApplicationService<Unblock, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: Unblock, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: Unblock, principal: Principal) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
|
||||||
|
|
||||||
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
val userDetail = userDetailRepository.findById(command.userDetailId)!!
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
|
|
||||||
val targetId = ActorId(command.targetActorId)
|
val targetId = ActorId(command.targetActorId)
|
||||||
|
|
|
@ -16,4 +16,6 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.unfollow
|
package dev.usbharu.hideout.core.application.relationship.unfollow
|
||||||
|
|
||||||
data class Unfollow(val targetActorId: Long)
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
|
data class Unfollow(val targetActorId: Long, val userDetailId: UserDetailId)
|
||||||
|
|
|
@ -18,13 +18,12 @@ package dev.usbharu.hideout.core.application.relationship.unfollow
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -37,10 +36,9 @@ class UserUnfollowApplicationService(
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<Unfollow, Unit>(transaction, logger) {
|
AbstractApplicationService<Unfollow, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: Unfollow, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: Unfollow, principal: Principal) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
|
||||||
|
|
||||||
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
val userDetail = userDetailRepository.findById(command.userDetailId)!!
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
|
|
||||||
val targetId = ActorId(command.targetActorId)
|
val targetId = ActorId(command.targetActorId)
|
||||||
|
|
|
@ -16,4 +16,6 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.relationship.unmute
|
package dev.usbharu.hideout.core.application.relationship.unmute
|
||||||
|
|
||||||
data class Unmute(val targetActorId: Long)
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
|
data class Unmute(val targetActorId: Long, val userDetailId: UserDetailId)
|
||||||
|
|
|
@ -18,13 +18,12 @@ package dev.usbharu.hideout.core.application.relationship.unmute
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
import dev.usbharu.hideout.core.application.relationship.block.UserBlockApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
import dev.usbharu.hideout.core.domain.model.relationship.Relationship
|
||||||
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.relationship.RelationshipRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -41,10 +40,9 @@ class UserUnmuteApplicationService(
|
||||||
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun internalExecute(command: Unmute, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: Unmute, principal: Principal) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
|
||||||
|
|
||||||
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
val userDetail = userDetailRepository.findById(command.userDetailId)!!
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
|
|
||||||
val targetId = ActorId(command.targetActorId)
|
val targetId = ActorId(command.targetActorId)
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.shared
|
package dev.usbharu.hideout.core.application.shared
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
|
|
||||||
|
@ -23,13 +24,13 @@ abstract class AbstractApplicationService<T : Any, R>(
|
||||||
protected val transaction: Transaction,
|
protected val transaction: Transaction,
|
||||||
protected val logger: Logger,
|
protected val logger: Logger,
|
||||||
) : ApplicationService<T, R> {
|
) : ApplicationService<T, R> {
|
||||||
override suspend fun execute(command: T, executor: CommandExecutor): R {
|
override suspend fun execute(command: T, principal: Principal): R {
|
||||||
return try {
|
return try {
|
||||||
logger.debug("START {} by {}", command::class.simpleName, executor)
|
logger.debug("START {}", command::class.simpleName)
|
||||||
val response = transaction.transaction<R> {
|
val response = transaction.transaction<R> {
|
||||||
internalExecute(command, executor)
|
internalExecute(command, principal)
|
||||||
}
|
}
|
||||||
logger.info("SUCCESS ${command::class.simpleName} by ${executor.executor}")
|
logger.info("SUCCESS ${command::class.simpleName}")
|
||||||
response
|
response
|
||||||
} catch (e: CancellationException) {
|
} catch (e: CancellationException) {
|
||||||
logger.debug("Coroutine canceled", e)
|
logger.debug("Coroutine canceled", e)
|
||||||
|
@ -40,5 +41,5 @@ abstract class AbstractApplicationService<T : Any, R>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract suspend fun internalExecute(command: T, executor: CommandExecutor): R
|
protected abstract suspend fun internalExecute(command: T, principal: Principal): R
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.shared
|
package dev.usbharu.hideout.core.application.shared
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
|
|
||||||
interface ApplicationService<T : Any, R> {
|
interface ApplicationService<T : Any, R> {
|
||||||
suspend fun execute(command: T, executor: CommandExecutor): R
|
suspend fun execute(command: T, principal: Principal): R
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package dev.usbharu.hideout.core.application.shared
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.FromApi
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
|
import org.slf4j.Logger
|
||||||
|
|
||||||
|
abstract class LocalUserAbstractApplicationService<T : Any, R>(transaction: Transaction, logger: Logger) :
|
||||||
|
AbstractApplicationService<T, R>(transaction, logger) {
|
||||||
|
override suspend fun internalExecute(command: T, principal: Principal): R {
|
||||||
|
require(principal is FromApi)
|
||||||
|
return internalExecute(command, principal)
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract suspend fun internalExecute(command: T, principal: FromApi): R
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package dev.usbharu.hideout.core.application.timeline
|
package dev.usbharu.hideout.core.application.timeline
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationshipRepository
|
import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationshipRepository
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -15,7 +15,7 @@ class UserAddTimelineRelationshipApplicationService(
|
||||||
AbstractApplicationService<AddTimelineRelationship, Unit>(
|
AbstractApplicationService<AddTimelineRelationship, Unit>(
|
||||||
transaction, logger
|
transaction, logger
|
||||||
) {
|
) {
|
||||||
override suspend fun internalExecute(command: AddTimelineRelationship, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: AddTimelineRelationship, principal: Principal) {
|
||||||
timelineRelationshipRepository.save(command.timelineRelationship)
|
timelineRelationshipRepository.save(command.timelineRelationship)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ class ActorDomainEventFactory(private val actor: Actor) {
|
||||||
class ActorEventBody(actor: Actor) : DomainEventBody(
|
class ActorEventBody(actor: Actor) : DomainEventBody(
|
||||||
mapOf(
|
mapOf(
|
||||||
"actor" to actor
|
"actor" to actor
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
enum class ActorEvent(val eventName: String, val collectable: Boolean = true) {
|
enum class ActorEvent(val eventName: String, val collectable: Boolean = true) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ActorInstanceRelationshipEventBody(actorInstanceRelationship: ActorInstanc
|
||||||
"muting" to actorInstanceRelationship.muting,
|
"muting" to actorInstanceRelationship.muting,
|
||||||
"blocking" to actorInstanceRelationship.blocking,
|
"blocking" to actorInstanceRelationship.blocking,
|
||||||
"doNotSendPrivate" to actorInstanceRelationship.doNotSendPrivate,
|
"doNotSendPrivate" to actorInstanceRelationship.doNotSendPrivate,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
enum class ActorInstanceRelationshipEvent(val eventName: String) {
|
enum class ActorInstanceRelationshipEvent(val eventName: String) {
|
||||||
|
|
|
@ -17,15 +17,20 @@
|
||||||
package dev.usbharu.hideout.core.domain.event.relationship
|
package dev.usbharu.hideout.core.domain.event.relationship
|
||||||
|
|
||||||
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.support.principal.Anonymous
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEvent
|
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEvent
|
||||||
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventBody
|
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventBody
|
||||||
|
|
||||||
class RelationshipEventFactory(private val relationship: Relationship) {
|
class RelationshipEventFactory(private val relationship: Relationship, private val principal: Principal = Anonymous) {
|
||||||
fun createEvent(relationshipEvent: RelationshipEvent): DomainEvent<RelationshipEventBody> =
|
fun createEvent(relationshipEvent: RelationshipEvent): DomainEvent<RelationshipEventBody> =
|
||||||
DomainEvent.create(relationshipEvent.eventName, RelationshipEventBody(relationship))
|
DomainEvent.create(relationshipEvent.eventName, RelationshipEventBody(relationship, principal))
|
||||||
}
|
}
|
||||||
|
|
||||||
class RelationshipEventBody(relationship: Relationship) : DomainEventBody(mapOf("relationship" to relationship)) {
|
class RelationshipEventBody(
|
||||||
|
relationship: Relationship,
|
||||||
|
override val principal: Principal
|
||||||
|
) : DomainEventBody(mapOf("relationship" to relationship), principal) {
|
||||||
fun getRelationship(): Relationship {
|
fun getRelationship(): Relationship {
|
||||||
return toMap()["relationship"] as Relationship
|
return toMap()["relationship"] as Relationship
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,6 @@ class Actor(
|
||||||
moveTo: ActorId? = null,
|
moveTo: ActorId? = null,
|
||||||
emojiIds: Set<EmojiId>,
|
emojiIds: Set<EmojiId>,
|
||||||
deleted: Boolean,
|
deleted: Boolean,
|
||||||
roles: Set<Role>,
|
|
||||||
icon: MediaId?,
|
icon: MediaId?,
|
||||||
banner: MediaId?,
|
banner: MediaId?,
|
||||||
) : DomainEventStorable() {
|
) : DomainEventStorable() {
|
||||||
|
@ -62,7 +61,7 @@ class Actor(
|
||||||
var banner = banner
|
var banner = banner
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun setBannerUrl(banner: MediaId?, actor: Actor) {
|
fun setBannerUrl(banner: MediaId?) {
|
||||||
addDomainEvent(ActorDomainEventFactory(this).createEvent(UPDATE))
|
addDomainEvent(ActorDomainEventFactory(this).createEvent(UPDATE))
|
||||||
this.banner = banner
|
this.banner = banner
|
||||||
}
|
}
|
||||||
|
@ -70,20 +69,11 @@ class Actor(
|
||||||
var icon = icon
|
var icon = icon
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun setIconUrl(icon: MediaId?, actor: Actor) {
|
fun setIconUrl(icon: MediaId?) {
|
||||||
addDomainEvent(ActorDomainEventFactory(this).createEvent(UPDATE))
|
addDomainEvent(ActorDomainEventFactory(this).createEvent(UPDATE))
|
||||||
this.icon = icon
|
this.icon = icon
|
||||||
}
|
}
|
||||||
|
|
||||||
var roles = roles
|
|
||||||
private set
|
|
||||||
|
|
||||||
fun setRole(roles: Set<Role>, actor: Actor) {
|
|
||||||
require(actor.roles.contains(Role.ADMINISTRATOR))
|
|
||||||
|
|
||||||
this.roles = roles
|
|
||||||
}
|
|
||||||
|
|
||||||
var suspend = suspend
|
var suspend = suspend
|
||||||
set(value) {
|
set(value) {
|
||||||
if (field != value && value) {
|
if (field != value && value) {
|
||||||
|
|
|
@ -20,11 +20,9 @@ import dev.usbharu.hideout.core.domain.event.post.PostDomainEventFactory
|
||||||
import dev.usbharu.hideout.core.domain.event.post.PostEvent
|
import dev.usbharu.hideout.core.domain.event.post.PostEvent
|
||||||
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.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.Role
|
|
||||||
import dev.usbharu.hideout.core.domain.model.emoji.EmojiId
|
import dev.usbharu.hideout.core.domain.model.emoji.EmojiId
|
||||||
import dev.usbharu.hideout.core.domain.model.instance.InstanceId
|
import dev.usbharu.hideout.core.domain.model.instance.InstanceId
|
||||||
import dev.usbharu.hideout.core.domain.model.media.MediaId
|
import dev.usbharu.hideout.core.domain.model.media.MediaId
|
||||||
import dev.usbharu.hideout.core.domain.model.post.Post.Companion.Action.*
|
|
||||||
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable
|
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
@ -62,7 +60,6 @@ class Post(
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun setVisibility(visibility: Visibility, actor: Actor) {
|
fun setVisibility(visibility: Visibility, actor: Actor) {
|
||||||
require(isAllow(actor, UPDATE, this))
|
|
||||||
require(this.visibility != Visibility.DIRECT)
|
require(this.visibility != Visibility.DIRECT)
|
||||||
require(visibility != Visibility.DIRECT)
|
require(visibility != Visibility.DIRECT)
|
||||||
require(this.visibility.ordinal >= visibility.ordinal)
|
require(this.visibility.ordinal >= visibility.ordinal)
|
||||||
|
@ -79,7 +76,6 @@ class Post(
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun setVisibleActors(visibleActors: Set<ActorId>, actor: Actor) {
|
fun setVisibleActors(visibleActors: Set<ActorId>, actor: Actor) {
|
||||||
require(isAllow(actor, UPDATE, this))
|
|
||||||
require(deleted.not())
|
require(deleted.not())
|
||||||
if (visibility == Visibility.DIRECT) {
|
if (visibility == Visibility.DIRECT) {
|
||||||
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
|
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
|
||||||
|
@ -97,7 +93,6 @@ class Post(
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun setContent(content: PostContent, actor: Actor) {
|
fun setContent(content: PostContent, actor: Actor) {
|
||||||
require(isAllow(actor, UPDATE, this))
|
|
||||||
require(deleted.not())
|
require(deleted.not())
|
||||||
if (this.content != content) {
|
if (this.content != content) {
|
||||||
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
|
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
|
||||||
|
@ -115,7 +110,6 @@ class Post(
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun setOverview(overview: PostOverview?, actor: Actor) {
|
fun setOverview(overview: PostOverview?, actor: Actor) {
|
||||||
require(isAllow(actor, UPDATE, this))
|
|
||||||
require(deleted.not())
|
require(deleted.not())
|
||||||
if (this.overview != overview) {
|
if (this.overview != overview) {
|
||||||
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
|
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
|
||||||
|
@ -127,7 +121,6 @@ class Post(
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun setSensitive(sensitive: Boolean, actor: Actor) {
|
fun setSensitive(sensitive: Boolean, actor: Actor) {
|
||||||
isAllow(actor, UPDATE, this)
|
|
||||||
require(deleted.not())
|
require(deleted.not())
|
||||||
if (this.sensitive != sensitive) {
|
if (this.sensitive != sensitive) {
|
||||||
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
|
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
|
||||||
|
@ -161,7 +154,6 @@ class Post(
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun addMediaIds(mediaIds: List<MediaId>, actor: Actor) {
|
fun addMediaIds(mediaIds: List<MediaId>, actor: Actor) {
|
||||||
require(isAllow(actor, UPDATE, this))
|
|
||||||
require(deleted.not())
|
require(deleted.not())
|
||||||
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
|
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
|
||||||
this.mediaIds = this.mediaIds.plus(mediaIds).distinct()
|
this.mediaIds = this.mediaIds.plus(mediaIds).distinct()
|
||||||
|
@ -171,7 +163,6 @@ class Post(
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun delete(actor: Actor) {
|
fun delete(actor: Actor) {
|
||||||
isAllow(actor, DELETE, this)
|
|
||||||
if (deleted.not()) {
|
if (deleted.not()) {
|
||||||
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.DELETE))
|
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.DELETE))
|
||||||
content = PostContent.empty
|
content = PostContent.empty
|
||||||
|
@ -209,7 +200,6 @@ class Post(
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun moveTo(moveTo: PostId, actor: Actor) {
|
fun moveTo(moveTo: PostId, actor: Actor) {
|
||||||
require(isAllow(actor, MOVE, this))
|
|
||||||
require(this.moveTo == null)
|
require(this.moveTo == null)
|
||||||
this.moveTo = moveTo
|
this.moveTo = moveTo
|
||||||
}
|
}
|
||||||
|
@ -324,26 +314,5 @@ class Post(
|
||||||
return post
|
return post
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isAllow(actor: Actor, action: Action, resource: Post): Boolean {
|
|
||||||
return when (action) {
|
|
||||||
UPDATE -> {
|
|
||||||
resource.actorId == actor.id || actor.roles.contains(Role.ADMINISTRATOR) || actor.roles.contains(
|
|
||||||
Role.MODERATOR
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
MOVE -> resource.actorId == actor.id && actor.deleted.not()
|
|
||||||
DELETE ->
|
|
||||||
resource.actorId == actor.id ||
|
|
||||||
actor.roles.contains(Role.ADMINISTRATOR) ||
|
|
||||||
actor.roles.contains(Role.MODERATOR)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class Action {
|
|
||||||
UPDATE,
|
|
||||||
MOVE,
|
|
||||||
DELETE,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package dev.usbharu.hideout.core.domain.model.support.acct
|
||||||
|
|
||||||
|
data class Acct(
|
||||||
|
val userpart: String,
|
||||||
|
val host: String
|
||||||
|
) {
|
||||||
|
override fun toString(): String {
|
||||||
|
return "acct:$userpart@$host"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package dev.usbharu.hideout.core.domain.model.support.principal
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
|
|
||||||
|
data object Anonymous : Principal(ActorId.ghost, null, null)
|
|
@ -0,0 +1,10 @@
|
||||||
|
package dev.usbharu.hideout.core.domain.model.support.principal
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.acct.Acct
|
||||||
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
|
class FromApi(actorId: ActorId, override val userDetailId: UserDetailId, override val acct: Acct) : Principal(
|
||||||
|
actorId, userDetailId,
|
||||||
|
acct
|
||||||
|
)
|
|
@ -0,0 +1,7 @@
|
||||||
|
package dev.usbharu.hideout.core.domain.model.support.principal
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.acct.Acct
|
||||||
|
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||||
|
|
||||||
|
sealed class Principal(open val actorId: ActorId, open val userDetailId: UserDetailId?, open val acct: Acct?)
|
|
@ -20,6 +20,6 @@ interface UserDetailRepository {
|
||||||
suspend fun save(userDetail: UserDetail): UserDetail
|
suspend fun save(userDetail: UserDetail): UserDetail
|
||||||
suspend fun delete(userDetail: UserDetail)
|
suspend fun delete(userDetail: UserDetail)
|
||||||
suspend fun findByActorId(actorId: Long): UserDetail?
|
suspend fun findByActorId(actorId: Long): UserDetail?
|
||||||
suspend fun findById(id: Long): UserDetail?
|
suspend fun findById(userDetailId: UserDetailId): UserDetail?
|
||||||
suspend fun findAllById(idList: List<UserDetailId>): List<UserDetail>
|
suspend fun findAllById(idList: List<UserDetailId>): List<UserDetail>
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.domain.shared.domainevent
|
package dev.usbharu.hideout.core.domain.shared.domainevent
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
|
|
||||||
@Suppress("UnnecessaryAbstractClass")
|
@Suppress("UnnecessaryAbstractClass")
|
||||||
abstract class DomainEventBody(private val map: Map<String, Any?>) {
|
abstract class DomainEventBody(private val map: Map<String, Any?>, open val principal: Principal? = null) {
|
||||||
fun toMap(): Map<String, Any?> = map
|
fun toMap(): Map<String, Any?> = map
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,6 @@ class ActorResultRowMapper : ResultRowMapper<Actor> {
|
||||||
.map { EmojiId(it.toLong()) }
|
.map { EmojiId(it.toLong()) }
|
||||||
.toSet(),
|
.toSet(),
|
||||||
deleted = resultRow[Actors.deleted],
|
deleted = resultRow[Actors.deleted],
|
||||||
roles = emptySet(),
|
|
||||||
icon = resultRow[Actors.icon]?.let { MediaId(it) },
|
icon = resultRow[Actors.icon]?.let { MediaId(it) },
|
||||||
banner = resultRow[Actors.banner]?.let { MediaId(it) }
|
banner = resultRow[Actors.banner]?.let { MediaId(it) }
|
||||||
)
|
)
|
||||||
|
|
|
@ -69,9 +69,9 @@ class UserDetailRepositoryImpl : UserDetailRepository, AbstractRepository() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun findById(id: Long): UserDetail? = query {
|
override suspend fun findById(id: UserDetailId): UserDetail? = query {
|
||||||
UserDetails
|
UserDetails
|
||||||
.selectAll().where { UserDetails.id eq id }
|
.selectAll().where { UserDetails.id eq id.id }
|
||||||
.singleOrNull()
|
.singleOrNull()
|
||||||
?.let {
|
?.let {
|
||||||
userDetail(it)
|
userDetail(it)
|
||||||
|
|
|
@ -61,7 +61,6 @@ class ActorFactoryImpl(
|
||||||
suspend = false,
|
suspend = false,
|
||||||
emojiIds = emptySet(),
|
emojiIds = emptySet(),
|
||||||
deleted = false,
|
deleted = false,
|
||||||
roles = emptySet(),
|
|
||||||
banner = null,
|
banner = null,
|
||||||
icon = null
|
icon = null
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,6 +18,7 @@ package dev.usbharu.hideout.core.interfaces.api.auth
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.actor.RegisterLocalActor
|
import dev.usbharu.hideout.core.application.actor.RegisterLocalActor
|
||||||
import dev.usbharu.hideout.core.application.actor.RegisterLocalActorApplicationService
|
import dev.usbharu.hideout.core.application.actor.RegisterLocalActorApplicationService
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Anonymous
|
||||||
import dev.usbharu.hideout.core.infrastructure.springframework.SpringMvcCommandExecutorFactory
|
import dev.usbharu.hideout.core.infrastructure.springframework.SpringMvcCommandExecutorFactory
|
||||||
import jakarta.servlet.http.HttpServletRequest
|
import jakarta.servlet.http.HttpServletRequest
|
||||||
import org.springframework.stereotype.Controller
|
import org.springframework.stereotype.Controller
|
||||||
|
@ -39,8 +40,7 @@ class AuthController(
|
||||||
suspend fun signUp(@Validated @ModelAttribute signUpForm: SignUpForm, request: HttpServletRequest): String {
|
suspend fun signUp(@Validated @ModelAttribute signUpForm: SignUpForm, request: HttpServletRequest): String {
|
||||||
val registerLocalActor = RegisterLocalActor(signUpForm.username, signUpForm.password)
|
val registerLocalActor = RegisterLocalActor(signUpForm.username, signUpForm.password)
|
||||||
val uri = registerLocalActorApplicationService.execute(
|
val uri = registerLocalActorApplicationService.execute(
|
||||||
registerLocalActor,
|
registerLocalActor, Anonymous
|
||||||
springMvcCommandExecutorFactory.getCommandExecutor()
|
|
||||||
)
|
)
|
||||||
request.login(signUpForm.username, signUpForm.password)
|
request.login(signUpForm.username, signUpForm.password)
|
||||||
return "redirect:$uri"
|
return "redirect:$uri"
|
||||||
|
|
|
@ -3,7 +3,6 @@ package dev.usbharu.hideout.core.domain.model.actor
|
||||||
import dev.usbharu.hideout.core.domain.event.actor.ActorEvent
|
import dev.usbharu.hideout.core.domain.event.actor.ActorEvent
|
||||||
import dev.usbharu.hideout.core.domain.model.media.MediaId
|
import dev.usbharu.hideout.core.domain.model.media.MediaId
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.assertDoesNotThrow
|
|
||||||
import org.junit.jupiter.api.assertThrows
|
import org.junit.jupiter.api.assertThrows
|
||||||
import utils.AssertDomainEvent.assertContainsEvent
|
import utils.AssertDomainEvent.assertContainsEvent
|
||||||
import utils.AssertDomainEvent.assertEmpty
|
import utils.AssertDomainEvent.assertEmpty
|
||||||
|
@ -134,7 +133,7 @@ class ActorsTest {
|
||||||
fun bannerが設定されたらupdateイベントが発生する() {
|
fun bannerが設定されたらupdateイベントが発生する() {
|
||||||
val actor = TestActorFactory.create(publicKey = ActorPublicKey(""))
|
val actor = TestActorFactory.create(publicKey = ActorPublicKey(""))
|
||||||
|
|
||||||
actor.setBannerUrl(MediaId(1), actor)
|
actor.setBannerUrl(MediaId(1))
|
||||||
|
|
||||||
assertContainsEvent(actor, ActorEvent.UPDATE.eventName)
|
assertContainsEvent(actor, ActorEvent.UPDATE.eventName)
|
||||||
}
|
}
|
||||||
|
@ -143,30 +142,8 @@ class ActorsTest {
|
||||||
fun iconが設定されたらupdateイベントが発生する() {
|
fun iconが設定されたらupdateイベントが発生する() {
|
||||||
val actor = TestActorFactory.create(publicKey = ActorPublicKey(""))
|
val actor = TestActorFactory.create(publicKey = ActorPublicKey(""))
|
||||||
|
|
||||||
actor.setIconUrl(MediaId(1), actor)
|
actor.setIconUrl(MediaId(1))
|
||||||
|
|
||||||
assertContainsEvent(actor, ActorEvent.UPDATE.eventName)
|
assertContainsEvent(actor, ActorEvent.UPDATE.eventName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun administratorロールを持っている人はroleを設定できる() {
|
|
||||||
val admin = TestActorFactory.create(roles = setOf(Role.ADMINISTRATOR))
|
|
||||||
|
|
||||||
val actor = TestActorFactory.create()
|
|
||||||
|
|
||||||
assertDoesNotThrow {
|
|
||||||
actor.setRole(setOf(Role.MODERATOR), admin)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun administratorロールを持ってないとはroleを設定できない() {
|
|
||||||
val admin = TestActorFactory.create(roles = setOf(Role.MODERATOR))
|
|
||||||
|
|
||||||
val actor = TestActorFactory.create()
|
|
||||||
|
|
||||||
assertThrows<IllegalArgumentException> {
|
|
||||||
actor.setRole(setOf(Role.MODERATOR), admin)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -66,7 +66,6 @@ object TestActorFactory {
|
||||||
moveTo = moveTo?.let { ActorId(it) },
|
moveTo = moveTo?.let { ActorId(it) },
|
||||||
emojiIds = emojiIds,
|
emojiIds = emojiIds,
|
||||||
deleted = deleted,
|
deleted = deleted,
|
||||||
roles = roles,
|
|
||||||
icon = null,
|
icon = null,
|
||||||
banner = null,
|
banner = null,
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
package dev.usbharu.hideout.mastodon.application.accounts
|
package dev.usbharu.hideout.mastodon.application.accounts
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.Account
|
import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.Account
|
||||||
import dev.usbharu.hideout.mastodon.query.AccountQueryService
|
import dev.usbharu.hideout.mastodon.query.AccountQueryService
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
@ -30,7 +30,7 @@ class GetAccountApplicationService(private val accountQueryService: AccountQuery
|
||||||
transaction,
|
transaction,
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
override suspend fun internalExecute(command: GetAccount, executor: CommandExecutor): Account {
|
override suspend fun internalExecute(command: GetAccount, principal: Principal): Account {
|
||||||
return accountQueryService.findById(command.accountId.toLong()) ?: throw Exception("Account not found")
|
return accountQueryService.findById(command.accountId.toLong()) ?: throw Exception("Account not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
package dev.usbharu.hideout.mastodon.application.filter
|
package dev.usbharu.hideout.mastodon.application.filter
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterKeywordId
|
import dev.usbharu.hideout.core.domain.model.filter.FilterKeywordId
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterRepository
|
import dev.usbharu.hideout.core.domain.model.filter.FilterRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class DeleteFilterV1ApplicationService(private val filterRepository: FilterRepos
|
||||||
private val logger = LoggerFactory.getLogger(DeleteFilterV1ApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(DeleteFilterV1ApplicationService::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun internalExecute(command: DeleteFilterV1, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: DeleteFilterV1, principal: Principal) {
|
||||||
val filter = filterRepository.findByFilterKeywordId(FilterKeywordId(command.filterKeywordId))
|
val filter = filterRepository.findByFilterKeywordId(FilterKeywordId(command.filterKeywordId))
|
||||||
?: throw Exception("Not Found")
|
?: throw Exception("Not Found")
|
||||||
filterRepository.delete(filter)
|
filterRepository.delete(filter)
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
package dev.usbharu.hideout.mastodon.application.filter
|
package dev.usbharu.hideout.mastodon.application.filter
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterContext.*
|
import dev.usbharu.hideout.core.domain.model.filter.FilterContext.*
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterKeywordId
|
import dev.usbharu.hideout.core.domain.model.filter.FilterKeywordId
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterMode
|
import dev.usbharu.hideout.core.domain.model.filter.FilterMode
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterRepository
|
import dev.usbharu.hideout.core.domain.model.filter.FilterRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.V1Filter
|
import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.V1Filter
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
@ -32,7 +32,7 @@ class GetFilterV1ApplicationService(private val filterRepository: FilterReposito
|
||||||
AbstractApplicationService<GetFilterV1, V1Filter>(
|
AbstractApplicationService<GetFilterV1, V1Filter>(
|
||||||
transaction, logger
|
transaction, logger
|
||||||
) {
|
) {
|
||||||
override suspend fun internalExecute(command: GetFilterV1, executor: CommandExecutor): V1Filter {
|
override suspend fun internalExecute(command: GetFilterV1, principal: Principal): V1Filter {
|
||||||
val filter = filterRepository.findByFilterKeywordId(FilterKeywordId(command.filterKeywordId))
|
val filter = filterRepository.findByFilterKeywordId(FilterKeywordId(command.filterKeywordId))
|
||||||
?: throw Exception("Not Found")
|
?: throw Exception("Not Found")
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
package dev.usbharu.hideout.mastodon.application.status
|
package dev.usbharu.hideout.mastodon.application.status
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.Status
|
import dev.usbharu.hideout.mastodon.interfaces.api.generated.model.Status
|
||||||
import dev.usbharu.hideout.mastodon.query.StatusQueryService
|
import dev.usbharu.hideout.mastodon.query.StatusQueryService
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
@ -36,7 +36,7 @@ class GetStatusApplicationService(
|
||||||
val logger = LoggerFactory.getLogger(GetStatusApplicationService::class.java)!!
|
val logger = LoggerFactory.getLogger(GetStatusApplicationService::class.java)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun internalExecute(command: GetStatus, executor: CommandExecutor): Status {
|
override suspend fun internalExecute(command: GetStatus, principal: Principal): Status {
|
||||||
return statusQueryService.findByPostId(command.id.toLong()) ?: throw Exception("Not fount")
|
return statusQueryService.findByPostId(command.id.toLong()) ?: throw Exception("Not fount")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -67,7 +67,7 @@ class SpringAccountApi(
|
||||||
|
|
||||||
override suspend fun apiV1AccountsIdBlockPost(id: String): ResponseEntity<Relationship> {
|
override suspend fun apiV1AccountsIdBlockPost(id: String): ResponseEntity<Relationship> {
|
||||||
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
||||||
userBlockApplicationService.execute(Block(id.toLong()), executor)
|
userBlockApplicationService.execute(Block(id.toLong()))
|
||||||
return fetchRelationship(id, executor)
|
return fetchRelationship(id, executor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class SpringAccountApi(
|
||||||
): ResponseEntity<Relationship> {
|
): ResponseEntity<Relationship> {
|
||||||
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
||||||
userFollowRequestApplicationService.execute(
|
userFollowRequestApplicationService.execute(
|
||||||
FollowRequest(id.toLong()), executor
|
FollowRequest(id.toLong())
|
||||||
)
|
)
|
||||||
return fetchRelationship(id, executor)
|
return fetchRelationship(id, executor)
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ class SpringAccountApi(
|
||||||
id: String,
|
id: String,
|
||||||
executor: Oauth2CommandExecutor,
|
executor: Oauth2CommandExecutor,
|
||||||
): ResponseEntity<Relationship> {
|
): ResponseEntity<Relationship> {
|
||||||
val relationship = getRelationshipApplicationService.execute(GetRelationship(id.toLong()), executor)
|
val relationship = getRelationshipApplicationService.execute(GetRelationship(id.toLong()))
|
||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
Relationship(
|
Relationship(
|
||||||
id = relationship.targetId.toString(),
|
id = relationship.targetId.toString(),
|
||||||
|
@ -109,8 +109,7 @@ class SpringAccountApi(
|
||||||
override suspend fun apiV1AccountsIdGet(id: String): ResponseEntity<Account> {
|
override suspend fun apiV1AccountsIdGet(id: String): ResponseEntity<Account> {
|
||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
getAccountApplicationService.execute(
|
getAccountApplicationService.execute(
|
||||||
GetAccount(id),
|
GetAccount(id)
|
||||||
oauth2CommandExecutorFactory.getCommandExecutor()
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -118,7 +117,7 @@ class SpringAccountApi(
|
||||||
override suspend fun apiV1AccountsIdMutePost(id: String): ResponseEntity<Relationship> {
|
override suspend fun apiV1AccountsIdMutePost(id: String): ResponseEntity<Relationship> {
|
||||||
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
||||||
userMuteApplicationService.execute(
|
userMuteApplicationService.execute(
|
||||||
Mute(id.toLong()), executor
|
Mute(id.toLong())
|
||||||
)
|
)
|
||||||
return fetchRelationship(id, executor)
|
return fetchRelationship(id, executor)
|
||||||
}
|
}
|
||||||
|
@ -126,7 +125,7 @@ class SpringAccountApi(
|
||||||
override suspend fun apiV1AccountsIdRemoveFromFollowersPost(id: String): ResponseEntity<Relationship> {
|
override suspend fun apiV1AccountsIdRemoveFromFollowersPost(id: String): ResponseEntity<Relationship> {
|
||||||
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
||||||
userRemoveFromFollowersApplicationService.execute(
|
userRemoveFromFollowersApplicationService.execute(
|
||||||
RemoveFromFollowers(id.toLong()), executor
|
RemoveFromFollowers(id.toLong())
|
||||||
)
|
)
|
||||||
return fetchRelationship(id, executor)
|
return fetchRelationship(id, executor)
|
||||||
}
|
}
|
||||||
|
@ -134,7 +133,7 @@ class SpringAccountApi(
|
||||||
override suspend fun apiV1AccountsIdUnblockPost(id: String): ResponseEntity<Relationship> {
|
override suspend fun apiV1AccountsIdUnblockPost(id: String): ResponseEntity<Relationship> {
|
||||||
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
||||||
userUnblockApplicationService.execute(
|
userUnblockApplicationService.execute(
|
||||||
Unblock(id.toLong()), executor
|
Unblock(id.toLong())
|
||||||
)
|
)
|
||||||
return fetchRelationship(id, executor)
|
return fetchRelationship(id, executor)
|
||||||
}
|
}
|
||||||
|
@ -142,7 +141,7 @@ class SpringAccountApi(
|
||||||
override suspend fun apiV1AccountsIdUnfollowPost(id: String): ResponseEntity<Relationship> {
|
override suspend fun apiV1AccountsIdUnfollowPost(id: String): ResponseEntity<Relationship> {
|
||||||
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
||||||
userUnfollowApplicationService.execute(
|
userUnfollowApplicationService.execute(
|
||||||
Unfollow(id.toLong()), executor
|
Unfollow(id.toLong())
|
||||||
)
|
)
|
||||||
return fetchRelationship(id, executor)
|
return fetchRelationship(id, executor)
|
||||||
}
|
}
|
||||||
|
@ -150,7 +149,7 @@ class SpringAccountApi(
|
||||||
override suspend fun apiV1AccountsIdUnmutePost(id: String): ResponseEntity<Relationship> {
|
override suspend fun apiV1AccountsIdUnmutePost(id: String): ResponseEntity<Relationship> {
|
||||||
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
||||||
userUnmuteApplicationService.execute(
|
userUnmuteApplicationService.execute(
|
||||||
Unmute(id.toLong()), executor
|
Unmute(id.toLong())
|
||||||
)
|
)
|
||||||
return fetchRelationship(id, executor)
|
return fetchRelationship(id, executor)
|
||||||
}
|
}
|
||||||
|
@ -166,7 +165,7 @@ class SpringAccountApi(
|
||||||
override suspend fun apiV1AccountsVerifyCredentialsGet(): ResponseEntity<CredentialAccount> {
|
override suspend fun apiV1AccountsVerifyCredentialsGet(): ResponseEntity<CredentialAccount> {
|
||||||
val commandExecutor = oauth2CommandExecutorFactory.getCommandExecutor()
|
val commandExecutor = oauth2CommandExecutorFactory.getCommandExecutor()
|
||||||
val localActor =
|
val localActor =
|
||||||
getUserDetailApplicationService.execute(GetUserDetail(commandExecutor.userDetailId), commandExecutor)
|
getUserDetailApplicationService.execute(GetUserDetail(commandExecutor.userDetailId))
|
||||||
|
|
||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
CredentialAccount(
|
CredentialAccount(
|
||||||
|
@ -218,7 +217,7 @@ class SpringAccountApi(
|
||||||
override suspend fun apiV1FollowRequestsAccountIdAuthorizePost(accountId: String): ResponseEntity<Relationship> {
|
override suspend fun apiV1FollowRequestsAccountIdAuthorizePost(accountId: String): ResponseEntity<Relationship> {
|
||||||
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
||||||
userAcceptFollowRequestApplicationService.execute(
|
userAcceptFollowRequestApplicationService.execute(
|
||||||
AcceptFollowRequest(accountId.toLong()), executor
|
AcceptFollowRequest(accountId.toLong())
|
||||||
)
|
)
|
||||||
return fetchRelationship(accountId, executor)
|
return fetchRelationship(accountId, executor)
|
||||||
}
|
}
|
||||||
|
@ -226,7 +225,7 @@ class SpringAccountApi(
|
||||||
override suspend fun apiV1FollowRequestsAccountIdRejectPost(accountId: String): ResponseEntity<Relationship> {
|
override suspend fun apiV1FollowRequestsAccountIdRejectPost(accountId: String): ResponseEntity<Relationship> {
|
||||||
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
val executor = oauth2CommandExecutorFactory.getCommandExecutor()
|
||||||
userRejectFollowRequestApplicationService.execute(
|
userRejectFollowRequestApplicationService.execute(
|
||||||
RejectFollowRequest(accountId.toLong()), executor
|
RejectFollowRequest(accountId.toLong())
|
||||||
)
|
)
|
||||||
return fetchRelationship(accountId, executor)
|
return fetchRelationship(accountId, executor)
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,7 @@ class SpringFilterApi(
|
||||||
override suspend fun apiV1FiltersIdDelete(id: String): ResponseEntity<Any> {
|
override suspend fun apiV1FiltersIdDelete(id: String): ResponseEntity<Any> {
|
||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
deleteFilterV1ApplicationService.execute(
|
deleteFilterV1ApplicationService.execute(
|
||||||
DeleteFilterV1(id.toLong()),
|
DeleteFilterV1(id.toLong())
|
||||||
oauth2CommandExecutorFactory.getCommandExecutor()
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -56,8 +55,7 @@ class SpringFilterApi(
|
||||||
override suspend fun apiV1FiltersIdGet(id: String): ResponseEntity<V1Filter> {
|
override suspend fun apiV1FiltersIdGet(id: String): ResponseEntity<V1Filter> {
|
||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
getFilterV1ApplicationService.execute(
|
getFilterV1ApplicationService.execute(
|
||||||
GetFilterV1(id.toLong()),
|
GetFilterV1(id.toLong())
|
||||||
oauth2CommandExecutorFactory.getCommandExecutor()
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -93,12 +91,11 @@ class SpringFilterApi(
|
||||||
RegisterFilter(
|
RegisterFilter(
|
||||||
v1FilterPostRequest.phrase, filterContext, FilterAction.WARN,
|
v1FilterPostRequest.phrase, filterContext, FilterAction.WARN,
|
||||||
setOf(RegisterFilterKeyword(v1FilterPostRequest.phrase, filterMode))
|
setOf(RegisterFilterKeyword(v1FilterPostRequest.phrase, filterMode))
|
||||||
), executor
|
)
|
||||||
)
|
)
|
||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
getFilterV1ApplicationService.execute(
|
getFilterV1ApplicationService.execute(
|
||||||
GetFilterV1(filter.filterKeywords.first().id),
|
GetFilterV1(filter.filterKeywords.first().id)
|
||||||
executor
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -119,16 +116,14 @@ class SpringFilterApi(
|
||||||
|
|
||||||
override suspend fun apiV2FiltersIdDelete(id: String): ResponseEntity<Any> {
|
override suspend fun apiV2FiltersIdDelete(id: String): ResponseEntity<Any> {
|
||||||
userDeleteFilterApplicationService.execute(
|
userDeleteFilterApplicationService.execute(
|
||||||
DeleteFilter(id.toLong()),
|
DeleteFilter(id.toLong())
|
||||||
oauth2CommandExecutorFactory.getCommandExecutor()
|
|
||||||
)
|
)
|
||||||
return ResponseEntity.ok(Unit)
|
return ResponseEntity.ok(Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun apiV2FiltersIdGet(id: String): ResponseEntity<Filter> {
|
override suspend fun apiV2FiltersIdGet(id: String): ResponseEntity<Filter> {
|
||||||
val filter = userGetFilterApplicationService.execute(
|
val filter = userGetFilterApplicationService.execute(
|
||||||
GetFilter(id.toLong()),
|
GetFilter(id.toLong())
|
||||||
oauth2CommandExecutorFactory.getCommandExecutor()
|
|
||||||
)
|
)
|
||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
filter(filter)
|
filter(filter)
|
||||||
|
@ -221,7 +216,7 @@ class SpringFilterApi(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}.toSet()
|
}.toSet()
|
||||||
), executor
|
)
|
||||||
)
|
)
|
||||||
return ResponseEntity.ok(filter(filter))
|
return ResponseEntity.ok(filter(filter))
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,7 @@ class SpringMediaApi(
|
||||||
file.originalFilename ?: file.name,
|
file.originalFilename ?: file.name,
|
||||||
null,
|
null,
|
||||||
description
|
description
|
||||||
),
|
)
|
||||||
oauth2CommandExecutorFactory.getCommandExecutor()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
|
|
|
@ -48,8 +48,7 @@ class SpringStatusApi(
|
||||||
|
|
||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
getStatusApplicationService.execute(
|
getStatusApplicationService.execute(
|
||||||
GetStatus(id),
|
GetStatus(id)
|
||||||
delegateCommandExecutorFactory.getCommandExecutor()
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -72,12 +71,11 @@ class SpringStatusApi(
|
||||||
replyId = statusesRequest.inReplyToId?.toLong(),
|
replyId = statusesRequest.inReplyToId?.toLong(),
|
||||||
sensitive = statusesRequest.sensitive == true,
|
sensitive = statusesRequest.sensitive == true,
|
||||||
mediaIds = statusesRequest.mediaIds.orEmpty().map { it.toLong() }
|
mediaIds = statusesRequest.mediaIds.orEmpty().map { it.toLong() }
|
||||||
),
|
)
|
||||||
executor
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
val status = getStatusApplicationService.execute(GetStatus(execute.toString()), executor)
|
val status = getStatusApplicationService.execute(GetStatus(execute.toString()))
|
||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
status
|
status
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue