From f5fc4fd0eea969336b4848c449ff26b71325873c Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Tue, 6 Aug 2024 00:04:32 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=9A=E5=B0=91=E3=81=AE=E6=94=B9?= =?UTF-8?q?=E5=96=84=E3=81=AB=E3=81=AF=E3=81=AA=E3=81=A3=E3=81=9F=E3=81=A0?= =?UTF-8?q?=E3=82=8D=E3=81=86=E3=81=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actor/GetUserDetailApplicationService.kt | 3 ++- .../actor/RegisterLocalActorApplicationService.kt | 3 ++- .../TimelineRelationshipFollowSubscriber.kt | 2 +- .../filter/UserDeleteFilterApplicationService.kt | 3 ++- .../filter/UserGetFilterApplicationService.kt | 3 ++- .../UserRegisterFilterApplicationService.kt | 3 ++- .../media/UploadMediaApplicationService.kt | 3 ++- .../application/post/GetPostApplicationService.kt | 3 ++- .../post/RegisterLocalPostApplicationService.kt | 3 ++- .../post/UpdateLocalNoteApplicationService.kt | 3 ++- .../UserAcceptFollowRequestApplicationService.kt | 3 ++- .../block/UserBlockApplicationService.kt | 3 ++- .../UserFollowRequestApplicationService.kt | 3 ++- .../get/GetRelationshipApplicationService.kt | 3 ++- .../mute/UserMuteApplicationService.kt | 3 ++- .../UserRejectFollowRequestApplicationService.kt | 3 ++- .../UserRemoveFromFollowersApplicationService.kt | 3 ++- .../unblock/UserUnblockApplicationService.kt | 3 ++- .../unfollow/UserUnfollowApplicationService.kt | 3 ++- .../unmute/UserUnmuteApplicationService.kt | 3 ++- .../shared/AbstractApplicationService.kt | 7 ++++--- .../core/application/shared/ApplicationService.kt | 4 +++- .../shared/LocalUserAbstractApplicationService.kt | 15 +++++++++++++++ ...erAddTimelineRelationshipApplicationService.kt | 3 ++- .../hideout/core/domain/event/actor/ActorEvent.kt | 2 +- .../ActorInstanceRelationshipEvent.kt | 2 +- .../event/relationship/RelationshipEvent.kt | 11 ++++++++--- .../core/domain/model/support/acct/Acct.kt | 10 ++++++++++ .../domain/model/support/principal/Anonymous.kt | 5 +++++ .../domain/model/support/principal/FromApi.kt | 10 ++++++++++ .../domain/model/support/principal/Principal.kt | 7 +++++++ .../domain/shared/domainevent/DomainEventBody.kt | 4 +++- .../core/interfaces/api/auth/AuthController.kt | 3 ++- .../accounts/GetAccountApplicationService.kt | 3 ++- .../filter/DeleteFilterV1ApplicationService.kt | 3 ++- .../filter/GetFilterV1ApplicationService.kt | 3 ++- .../status/GetStatusApplicationService.kt | 3 ++- 37 files changed, 118 insertions(+), 36 deletions(-) create mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/shared/LocalUserAbstractApplicationService.kt create mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/acct/Acct.kt create mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/Anonymous.kt create mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/FromApi.kt create mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/Principal.kt diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/GetUserDetailApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/GetUserDetailApplicationService.kt index 0cee7c45..1b025ed4 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/GetUserDetailApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/GetUserDetailApplicationService.kt @@ -20,6 +20,7 @@ import dev.usbharu.hideout.core.application.shared.AbstractApplicationService import dev.usbharu.hideout.core.application.shared.Transaction import dev.usbharu.hideout.core.domain.model.actor.ActorRepository import dev.usbharu.hideout.core.domain.model.emoji.CustomEmojiRepository +import dev.usbharu.hideout.core.domain.model.support.principal.Principal import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository import org.slf4j.LoggerFactory @@ -33,7 +34,7 @@ class GetUserDetailApplicationService( transaction: Transaction, ) : AbstractApplicationService(transaction, Companion.logger) { - override suspend fun internalExecute(command: GetUserDetail): UserDetail { + override suspend fun internalExecute(command: GetUserDetail, principal: Principal): UserDetail { val userDetail = userDetailRepository.findById(UserDetailId(command.id)) ?: throw IllegalArgumentException("actor does not exist") val actor = actorRepository.findById(userDetail.actorId)!! diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/RegisterLocalActorApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/RegisterLocalActorApplicationService.kt index f07e2679..5819b4c1 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/RegisterLocalActorApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/RegisterLocalActorApplicationService.kt @@ -21,6 +21,7 @@ import dev.usbharu.hideout.core.application.shared.Transaction import dev.usbharu.hideout.core.config.ApplicationConfig 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.support.principal.Principal 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.UserDetailRepository @@ -45,7 +46,7 @@ class RegisterLocalActorApplicationService( private val idGenerateService: IdGenerateService, ) : AbstractApplicationService(transaction, Companion.logger) { - override suspend fun internalExecute(command: RegisterLocalActor): URI { + override suspend fun internalExecute(command: RegisterLocalActor, principal: Principal): URI { if (actorDomainService.usernameAlreadyUse(command.name)) { // todo 適切な例外を考える throw Exception("Username already exists") diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/TimelineRelationshipFollowSubscriber.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/TimelineRelationshipFollowSubscriber.kt index b6830154..94aff5f3 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/TimelineRelationshipFollowSubscriber.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/TimelineRelationshipFollowSubscriber.kt @@ -36,7 +36,7 @@ class TimelineRelationshipFollowSubscriber( relationship.targetActorId, Visible.FOLLOWERS ) - ) + ), it.body.principal ) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/UserDeleteFilterApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/UserDeleteFilterApplicationService.kt index 789212cb..1d6dbb28 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/UserDeleteFilterApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/UserDeleteFilterApplicationService.kt @@ -20,6 +20,7 @@ import dev.usbharu.hideout.core.application.shared.AbstractApplicationService 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.FilterRepository +import dev.usbharu.hideout.core.domain.model.support.principal.Principal import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -29,7 +30,7 @@ class UserDeleteFilterApplicationService(private val filterRepository: FilterRep transaction, logger ) { - override suspend fun internalExecute(command: DeleteFilter) { + override suspend fun internalExecute(command: DeleteFilter, principal: Principal) { val filter = filterRepository.findByFilterId(FilterId(command.filterId)) ?: throw Exception("not found") filterRepository.delete(filter) } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/UserGetFilterApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/UserGetFilterApplicationService.kt index 3de348a6..fc7ea255 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/UserGetFilterApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/UserGetFilterApplicationService.kt @@ -20,6 +20,7 @@ import dev.usbharu.hideout.core.application.shared.AbstractApplicationService 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.FilterRepository +import dev.usbharu.hideout.core.domain.model.support.principal.Principal import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -29,7 +30,7 @@ class UserGetFilterApplicationService(private val filterRepository: FilterReposi transaction, logger ) { - override suspend fun internalExecute(command: GetFilter): Filter { + override suspend fun internalExecute(command: GetFilter, principal: Principal): Filter { val filter = filterRepository.findByFilterId(FilterId(command.filterId)) ?: throw Exception("Not Found") return Filter.of(filter) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/UserRegisterFilterApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/UserRegisterFilterApplicationService.kt index a64fcc2f..8bf5b3a3 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/UserRegisterFilterApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/UserRegisterFilterApplicationService.kt @@ -20,6 +20,7 @@ import dev.usbharu.hideout.core.application.shared.AbstractApplicationService import dev.usbharu.hideout.core.application.shared.Transaction import dev.usbharu.hideout.core.domain.model.filter.* import dev.usbharu.hideout.core.domain.model.filter.FilterKeyword +import dev.usbharu.hideout.core.domain.model.support.principal.Principal import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -35,7 +36,7 @@ class UserRegisterFilterApplicationService( logger ) { - override suspend fun internalExecute(command: RegisterFilter): Filter { + override suspend fun internalExecute(command: RegisterFilter, principal: Principal): Filter { val filter = dev.usbharu.hideout.core.domain.model.filter.Filter.create( id = FilterId(idGenerateService.generateId()), diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/media/UploadMediaApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/media/UploadMediaApplicationService.kt index 2c064885..909ab7f4 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/media/UploadMediaApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/media/UploadMediaApplicationService.kt @@ -19,6 +19,7 @@ package dev.usbharu.hideout.core.application.media import dev.usbharu.hideout.core.application.shared.AbstractApplicationService import dev.usbharu.hideout.core.application.shared.Transaction 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.external.media.MediaProcessor import dev.usbharu.hideout.core.external.mediastore.MediaStore @@ -38,7 +39,7 @@ class UploadMediaApplicationService( transaction, logger ) { - override suspend fun internalExecute(command: UploadMedia): Media { + override suspend fun internalExecute(command: UploadMedia, principal: Principal): Media { val process = mediaProcessor.process(command.path, command.name, null) val id = idGenerateService.generateId() val thumbnailUri = if (process.thumbnailPath != null) { diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/GetPostApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/GetPostApplicationService.kt index 6840b5ff..8cfde8e4 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/GetPostApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/GetPostApplicationService.kt @@ -20,6 +20,7 @@ import dev.usbharu.hideout.core.application.shared.AbstractApplicationService 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.PostRepository +import dev.usbharu.hideout.core.domain.model.support.principal.Principal import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -27,7 +28,7 @@ import org.springframework.stereotype.Service class GetPostApplicationService(private val postRepository: PostRepository, transaction: Transaction) : AbstractApplicationService(transaction, logger) { - override suspend fun internalExecute(command: GetPost): Post { + override suspend fun internalExecute(command: GetPost, principal: Principal): Post { val post = postRepository.findById(PostId(command.postId)) ?: throw Exception("Post not found") return Post.of(post) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/RegisterLocalPostApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/RegisterLocalPostApplicationService.kt index 9c0ce7d2..95bfe505 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/RegisterLocalPostApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/RegisterLocalPostApplicationService.kt @@ -23,6 +23,7 @@ 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.PostOverview 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.infrastructure.factory.PostFactoryImpl @@ -39,7 +40,7 @@ class RegisterLocalPostApplicationService( transaction: Transaction, ) : AbstractApplicationService(transaction, Companion.logger) { - override suspend fun internalExecute(command: RegisterLocalPost): Long { + override suspend fun internalExecute(command: RegisterLocalPost, principal: Principal): Long { val actorId = ( userDetailRepository.findById(UserDetailId(command.userDetailId)) ?: throw IllegalStateException("actor not found") diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/UpdateLocalNoteApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/UpdateLocalNoteApplicationService.kt index fa844f94..6a24184c 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/UpdateLocalNoteApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/UpdateLocalNoteApplicationService.kt @@ -23,6 +23,7 @@ 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.PostOverview 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.infrastructure.factory.PostContentFactoryImpl import org.slf4j.LoggerFactory @@ -37,7 +38,7 @@ class UpdateLocalNoteApplicationService( private val actorRepository: ActorRepository, ) : AbstractApplicationService(transaction, logger) { - override suspend fun internalExecute(command: UpdateLocalNote) { + override suspend fun internalExecute(command: UpdateLocalNote, principal: Principal) { val userDetail = userDetailRepository.findById(command.userDetailId)!! val actor = actorRepository.findById(userDetail.actorId)!! diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/acceptfollowrequest/UserAcceptFollowRequestApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/acceptfollowrequest/UserAcceptFollowRequestApplicationService.kt index 8d2fa88f..ef7a382a 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/acceptfollowrequest/UserAcceptFollowRequestApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/acceptfollowrequest/UserAcceptFollowRequestApplicationService.kt @@ -22,6 +22,7 @@ import dev.usbharu.hideout.core.application.shared.Transaction 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.relationship.RelationshipRepository +import dev.usbharu.hideout.core.domain.model.support.principal.Principal import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -34,7 +35,7 @@ class UserAcceptFollowRequestApplicationService( private val userDetailRepository: UserDetailRepository, ) : AbstractApplicationService(transaction, logger) { - override suspend fun internalExecute(command: AcceptFollowRequest) { + override suspend fun internalExecute(command: AcceptFollowRequest, principal: Principal) { val userDetail = userDetailRepository.findById(command.userDetailId)!! val actor = actorRepository.findById(userDetail.actorId)!! diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/block/UserBlockApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/block/UserBlockApplicationService.kt index 01f1f538..f8baa681 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/block/UserBlockApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/block/UserBlockApplicationService.kt @@ -22,6 +22,7 @@ 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.relationship.Relationship 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.service.relationship.RelationshipDomainService import org.slf4j.LoggerFactory @@ -36,7 +37,7 @@ class UserBlockApplicationService( private val relationshipDomainService: RelationshipDomainService, ) : AbstractApplicationService(transaction, logger) { - override suspend fun internalExecute(command: Block) { + override suspend fun internalExecute(command: Block, principal: Principal) { val userDetail = userDetailRepository.findById(command.userDetailId)!! val actor = actorRepository.findById(userDetail.actorId)!! diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/followrequest/UserFollowRequestApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/followrequest/UserFollowRequestApplicationService.kt index 3112a8d4..b1dfe181 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/followrequest/UserFollowRequestApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/followrequest/UserFollowRequestApplicationService.kt @@ -22,6 +22,7 @@ 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.relationship.Relationship 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 org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -37,7 +38,7 @@ class UserFollowRequestApplicationService( logger ) { - override suspend fun internalExecute(command: FollowRequest) { + override suspend fun internalExecute(command: FollowRequest, principal: Principal) { val userDetail = userDetailRepository.findById(command.userDetailId)!! val actor = actorRepository.findById(userDetail.actorId)!! diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/get/GetRelationshipApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/get/GetRelationshipApplicationService.kt index cc43f2fd..ecc8b6e7 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/get/GetRelationshipApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/get/GetRelationshipApplicationService.kt @@ -23,6 +23,7 @@ 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.ActorInstanceRelationshipRepository 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 org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -39,7 +40,7 @@ class GetRelationshipApplicationService( transaction, logger ) { - override suspend fun internalExecute(command: GetRelationship): Relationship { + override suspend fun internalExecute(command: GetRelationship, principal: Principal): Relationship { val userDetail = userDetailRepository.findById(command.userDetailId)!! val actor = actorRepository.findById(userDetail.actorId)!! val targetId = ActorId(command.targetActorId) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/mute/UserMuteApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/mute/UserMuteApplicationService.kt index f74f9bdf..999a76fc 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/mute/UserMuteApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/mute/UserMuteApplicationService.kt @@ -23,6 +23,7 @@ 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.relationship.Relationship 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 org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -35,7 +36,7 @@ class UserMuteApplicationService( private val userDetailRepository: UserDetailRepository, ) : AbstractApplicationService(transaction, logger) { - override suspend fun internalExecute(command: Mute) { + override suspend fun internalExecute(command: Mute, principal: Principal) { val userDetail = userDetailRepository.findById(command.userDetailId)!! val actor = actorRepository.findById(userDetail.actorId)!! diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/rejectfollowrequest/UserRejectFollowRequestApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/rejectfollowrequest/UserRejectFollowRequestApplicationService.kt index 612b09d4..b2f39da4 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/rejectfollowrequest/UserRejectFollowRequestApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/rejectfollowrequest/UserRejectFollowRequestApplicationService.kt @@ -22,6 +22,7 @@ import dev.usbharu.hideout.core.application.shared.Transaction 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.relationship.RelationshipRepository +import dev.usbharu.hideout.core.domain.model.support.principal.Principal import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -34,7 +35,7 @@ class UserRejectFollowRequestApplicationService( private val userDetailRepository: UserDetailRepository, ) : AbstractApplicationService(transaction, logger) { - override suspend fun internalExecute(command: RejectFollowRequest) { + override suspend fun internalExecute(command: RejectFollowRequest, principal: Principal) { val userDetail = userDetailRepository.findById(command.userDetailId)!! val actor = actorRepository.findById(userDetail.actorId)!! diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/removefromfollowers/UserRemoveFromFollowersApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/removefromfollowers/UserRemoveFromFollowersApplicationService.kt index 6014188e..2d6ab718 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/removefromfollowers/UserRemoveFromFollowersApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/removefromfollowers/UserRemoveFromFollowersApplicationService.kt @@ -23,6 +23,7 @@ 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.relationship.Relationship 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 org.slf4j.LoggerFactory @@ -36,7 +37,7 @@ class UserRemoveFromFollowersApplicationService( private val userDetailRepository: UserDetailRepository, ) : AbstractApplicationService(transaction, logger) { - override suspend fun internalExecute(command: RemoveFromFollowers) { + override suspend fun internalExecute(command: RemoveFromFollowers, principal: Principal) { val userDetail = userDetailRepository.findById(UserDetailId(command.userDetailId))!! val actor = actorRepository.findById(userDetail.actorId)!! diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/unblock/UserUnblockApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/unblock/UserUnblockApplicationService.kt index f8a98b30..fd8a1962 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/unblock/UserUnblockApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/unblock/UserUnblockApplicationService.kt @@ -23,6 +23,7 @@ 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.relationship.Relationship 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 org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -35,7 +36,7 @@ class UserUnblockApplicationService( private val userDetailRepository: UserDetailRepository, ) : AbstractApplicationService(transaction, logger) { - override suspend fun internalExecute(command: Unblock) { + override suspend fun internalExecute(command: Unblock, principal: Principal) { val userDetail = userDetailRepository.findById(command.userDetailId)!! val actor = actorRepository.findById(userDetail.actorId)!! diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/unfollow/UserUnfollowApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/unfollow/UserUnfollowApplicationService.kt index d611be06..9c44a183 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/unfollow/UserUnfollowApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/unfollow/UserUnfollowApplicationService.kt @@ -23,6 +23,7 @@ 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.relationship.Relationship 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 org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -35,7 +36,7 @@ class UserUnfollowApplicationService( private val userDetailRepository: UserDetailRepository, ) : AbstractApplicationService(transaction, logger) { - override suspend fun internalExecute(command: Unfollow) { + override suspend fun internalExecute(command: Unfollow, principal: Principal) { val userDetail = userDetailRepository.findById(command.userDetailId)!! val actor = actorRepository.findById(userDetail.actorId)!! diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/unmute/UserUnmuteApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/unmute/UserUnmuteApplicationService.kt index 605c3dea..2ddcd20a 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/unmute/UserUnmuteApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/unmute/UserUnmuteApplicationService.kt @@ -23,6 +23,7 @@ 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.relationship.Relationship 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 org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -39,7 +40,7 @@ class UserUnmuteApplicationService( private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java) } - override suspend fun internalExecute(command: Unmute) { + override suspend fun internalExecute(command: Unmute, principal: Principal) { val userDetail = userDetailRepository.findById(command.userDetailId)!! val actor = actorRepository.findById(userDetail.actorId)!! diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/shared/AbstractApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/shared/AbstractApplicationService.kt index 1262b4af..88f5de32 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/shared/AbstractApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/shared/AbstractApplicationService.kt @@ -16,6 +16,7 @@ package dev.usbharu.hideout.core.application.shared +import dev.usbharu.hideout.core.domain.model.support.principal.Principal import kotlinx.coroutines.CancellationException import org.slf4j.Logger @@ -23,11 +24,11 @@ abstract class AbstractApplicationService( protected val transaction: Transaction, protected val logger: Logger, ) : ApplicationService { - override suspend fun execute(command: T): R { + override suspend fun execute(command: T, principal: Principal): R { return try { logger.debug("START {}", command::class.simpleName) val response = transaction.transaction { - internalExecute(command) + internalExecute(command, principal) } logger.info("SUCCESS ${command::class.simpleName}") response @@ -40,5 +41,5 @@ abstract class AbstractApplicationService( } } - protected abstract suspend fun internalExecute(command: T): R + protected abstract suspend fun internalExecute(command: T, principal: Principal): R } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/shared/ApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/shared/ApplicationService.kt index 60498e44..6b2b3f02 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/shared/ApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/shared/ApplicationService.kt @@ -16,6 +16,8 @@ package dev.usbharu.hideout.core.application.shared +import dev.usbharu.hideout.core.domain.model.support.principal.Principal + interface ApplicationService { - suspend fun execute(command: T): R + suspend fun execute(command: T, principal: Principal): R } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/shared/LocalUserAbstractApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/shared/LocalUserAbstractApplicationService.kt new file mode 100644 index 00000000..e84702d2 --- /dev/null +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/shared/LocalUserAbstractApplicationService.kt @@ -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(transaction: Transaction, logger: Logger) : + AbstractApplicationService(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 +} \ No newline at end of file diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/timeline/UserAddTimelineRelationshipApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/timeline/UserAddTimelineRelationshipApplicationService.kt index f3132fdb..5bd0721f 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/timeline/UserAddTimelineRelationshipApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/timeline/UserAddTimelineRelationshipApplicationService.kt @@ -2,6 +2,7 @@ package dev.usbharu.hideout.core.application.timeline import dev.usbharu.hideout.core.application.shared.AbstractApplicationService 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 org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -14,7 +15,7 @@ class UserAddTimelineRelationshipApplicationService( AbstractApplicationService( transaction, logger ) { - override suspend fun internalExecute(command: AddTimelineRelationship) { + override suspend fun internalExecute(command: AddTimelineRelationship, principal: Principal) { timelineRelationshipRepository.save(command.timelineRelationship) } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/actor/ActorEvent.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/actor/ActorEvent.kt index fb2343e3..98f2918a 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/actor/ActorEvent.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/actor/ActorEvent.kt @@ -33,7 +33,7 @@ class ActorDomainEventFactory(private val actor: Actor) { class ActorEventBody(actor: Actor) : DomainEventBody( mapOf( "actor" to actor - ) + ), ) enum class ActorEvent(val eventName: String, val collectable: Boolean = true) { diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/actorinstancerelationship/ActorInstanceRelationshipEvent.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/actorinstancerelationship/ActorInstanceRelationshipEvent.kt index aabdd14a..ba92c969 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/actorinstancerelationship/ActorInstanceRelationshipEvent.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/actorinstancerelationship/ActorInstanceRelationshipEvent.kt @@ -39,7 +39,7 @@ class ActorInstanceRelationshipEventBody(actorInstanceRelationship: ActorInstanc "muting" to actorInstanceRelationship.muting, "blocking" to actorInstanceRelationship.blocking, "doNotSendPrivate" to actorInstanceRelationship.doNotSendPrivate, - ) + ), ) enum class ActorInstanceRelationshipEvent(val eventName: String) { diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/relationship/RelationshipEvent.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/relationship/RelationshipEvent.kt index 86937199..0681d9b7 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/relationship/RelationshipEvent.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/relationship/RelationshipEvent.kt @@ -17,15 +17,20 @@ package dev.usbharu.hideout.core.domain.event.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.DomainEventBody -class RelationshipEventFactory(private val relationship: Relationship) { +class RelationshipEventFactory(private val relationship: Relationship, private val principal: Principal = Anonymous) { fun createEvent(relationshipEvent: RelationshipEvent): DomainEvent = - 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 { return toMap()["relationship"] as Relationship } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/acct/Acct.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/acct/Acct.kt new file mode 100644 index 00000000..52394510 --- /dev/null +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/acct/Acct.kt @@ -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" + } +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/Anonymous.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/Anonymous.kt new file mode 100644 index 00000000..9bcc6cbb --- /dev/null +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/Anonymous.kt @@ -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) \ No newline at end of file diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/FromApi.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/FromApi.kt new file mode 100644 index 00000000..93215882 --- /dev/null +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/FromApi.kt @@ -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 +) \ No newline at end of file diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/Principal.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/Principal.kt new file mode 100644 index 00000000..6e7b939f --- /dev/null +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/Principal.kt @@ -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?) \ No newline at end of file diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/shared/domainevent/DomainEventBody.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/shared/domainevent/DomainEventBody.kt index 7c57d32c..bcee190b 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/shared/domainevent/DomainEventBody.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/shared/domainevent/DomainEventBody.kt @@ -16,7 +16,9 @@ package dev.usbharu.hideout.core.domain.shared.domainevent +import dev.usbharu.hideout.core.domain.model.support.principal.Principal + @Suppress("UnnecessaryAbstractClass") -abstract class DomainEventBody(private val map: Map) { +abstract class DomainEventBody(private val map: Map, open val principal: Principal? = null) { fun toMap(): Map = map } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/auth/AuthController.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/auth/AuthController.kt index 2bbdb7cb..64687efd 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/auth/AuthController.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/auth/AuthController.kt @@ -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.RegisterLocalActorApplicationService +import dev.usbharu.hideout.core.domain.model.support.principal.Anonymous import dev.usbharu.hideout.core.infrastructure.springframework.SpringMvcCommandExecutorFactory import jakarta.servlet.http.HttpServletRequest import org.springframework.stereotype.Controller @@ -39,7 +40,7 @@ class AuthController( suspend fun signUp(@Validated @ModelAttribute signUpForm: SignUpForm, request: HttpServletRequest): String { val registerLocalActor = RegisterLocalActor(signUpForm.username, signUpForm.password) val uri = registerLocalActorApplicationService.execute( - registerLocalActor + registerLocalActor, Anonymous ) request.login(signUpForm.username, signUpForm.password) return "redirect:$uri" diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/accounts/GetAccountApplicationService.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/accounts/GetAccountApplicationService.kt index bb399e07..d2611534 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/accounts/GetAccountApplicationService.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/accounts/GetAccountApplicationService.kt @@ -18,6 +18,7 @@ package dev.usbharu.hideout.mastodon.application.accounts import dev.usbharu.hideout.core.application.shared.AbstractApplicationService 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.query.AccountQueryService import org.slf4j.LoggerFactory @@ -29,7 +30,7 @@ class GetAccountApplicationService(private val accountQueryService: AccountQuery transaction, logger ) { - override suspend fun internalExecute(command: GetAccount): Account { + override suspend fun internalExecute(command: GetAccount, principal: Principal): Account { return accountQueryService.findById(command.accountId.toLong()) ?: throw Exception("Account not found") } diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/DeleteFilterV1ApplicationService.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/DeleteFilterV1ApplicationService.kt index 19a47658..2a722f01 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/DeleteFilterV1ApplicationService.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/DeleteFilterV1ApplicationService.kt @@ -20,6 +20,7 @@ import dev.usbharu.hideout.core.application.shared.AbstractApplicationService 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.FilterRepository +import dev.usbharu.hideout.core.domain.model.support.principal.Principal import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -32,7 +33,7 @@ class DeleteFilterV1ApplicationService(private val filterRepository: FilterRepos private val logger = LoggerFactory.getLogger(DeleteFilterV1ApplicationService::class.java) } - override suspend fun internalExecute(command: DeleteFilterV1) { + override suspend fun internalExecute(command: DeleteFilterV1, principal: Principal) { val filter = filterRepository.findByFilterKeywordId(FilterKeywordId(command.filterKeywordId)) ?: throw Exception("Not Found") filterRepository.delete(filter) diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/GetFilterV1ApplicationService.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/GetFilterV1ApplicationService.kt index c57b92ac..057b7b1a 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/GetFilterV1ApplicationService.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/filter/GetFilterV1ApplicationService.kt @@ -22,6 +22,7 @@ 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.FilterMode 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 org.slf4j.LoggerFactory import org.springframework.stereotype.Repository @@ -31,7 +32,7 @@ class GetFilterV1ApplicationService(private val filterRepository: FilterReposito AbstractApplicationService( transaction, logger ) { - override suspend fun internalExecute(command: GetFilterV1): V1Filter { + override suspend fun internalExecute(command: GetFilterV1, principal: Principal): V1Filter { val filter = filterRepository.findByFilterKeywordId(FilterKeywordId(command.filterKeywordId)) ?: throw Exception("Not Found") diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/status/GetStatusApplicationService.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/status/GetStatusApplicationService.kt index 66a9f650..63bccc23 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/status/GetStatusApplicationService.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/application/status/GetStatusApplicationService.kt @@ -18,6 +18,7 @@ package dev.usbharu.hideout.mastodon.application.status import dev.usbharu.hideout.core.application.shared.AbstractApplicationService 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.query.StatusQueryService import org.slf4j.LoggerFactory @@ -35,7 +36,7 @@ class GetStatusApplicationService( val logger = LoggerFactory.getLogger(GetStatusApplicationService::class.java)!! } - override suspend fun internalExecute(command: GetStatus): Status { + override suspend fun internalExecute(command: GetStatus, principal: Principal): Status { return statusQueryService.findByPostId(command.id.toLong()) ?: throw Exception("Not fount") } } \ No newline at end of file