From 6d997e8012c6f6daf5a66acb00cd065c0895a60f Mon Sep 17 00:00:00 2001 From: usbharu Date: Tue, 13 Aug 2024 11:16:14 +0000 Subject: [PATCH] style: fix lint (CI) --- .../MigrationLocalActorApplicationService.kt | 16 ++++---- .../RegisterApplicationApplicationService.kt | 1 - .../TimelineRelationshipFollowSubscriber.kt | 8 ++-- .../exception/InternalServerException.kt | 2 +- .../exception/PermissionDeniedException.kt | 2 +- .../UserRegisterFilterApplicationService.kt | 1 - .../GetLocalInstanceApplicationService.kt | 12 +++--- .../core/application/instance/Instance.kt | 5 ++- .../core/application/post/ActorDetail.kt | 3 +- .../post/DeleteLocalPostApplicationService.kt | 3 +- .../post/GetPostDetailApplicationService.kt | 12 ++++-- .../core/application/post/MediaDetail.kt | 2 +- ...erAcceptFollowRequestApplicationService.kt | 1 - .../block/UserBlockApplicationService.kt | 2 - .../get/GetRelationshipApplicationService.kt | 12 +++--- .../LocalUserAbstractApplicationService.kt | 2 +- ...dTimelineRelationshipApplicationService.kt | 5 ++- .../hideout/core/config/ApplicationConfig.kt | 2 +- .../core/domain/model/filter/Filter.kt | 1 - .../hideout/core/domain/model/post/Post.kt | 39 +++++++++---------- .../model/support/principal/Anonymous.kt | 2 +- .../model/support/principal/LocalUser.kt | 2 +- .../model/support/principal/Principal.kt | 2 +- .../principal/PrincipalContextHolder.kt | 2 +- .../model/timelineobject/TimelineObject.kt | 8 ++-- .../post/DefaultPostReadAccessControl.kt | 24 ++++++------ .../ExposedPrincipalQueryService.kt | 2 +- ...SecurityFormLoginPrincipalContextHolder.kt | 4 +- ...ingSecurityOauth2PrincipalContextHolder.kt | 2 +- .../InternalTimelineObjectRepository.kt | 2 +- .../interfaces/api/auth/AuthController.kt | 3 +- .../api/media/LocalFileController.kt | 3 +- .../interfaces/web/posts/PostsController.kt | 2 +- .../interfaces/web/posts/PublishController.kt | 4 +- .../core/query/principal/PrincipalDTO.kt | 2 +- .../query/principal/PrincipalQueryService.kt | 2 +- 36 files changed, 99 insertions(+), 98 deletions(-) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/MigrationLocalActorApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/MigrationLocalActorApplicationService.kt index a9198f67..ea9b8313 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/MigrationLocalActorApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/MigrationLocalActorApplicationService.kt @@ -58,13 +58,15 @@ class MigrationLocalActorApplicationService( if (canAccountMigration.canMigration) { fromActor.moveTo = toActorId actorRepository.save(fromActor) - } else when (canAccountMigration) { - is AlreadyMoved -> throw IllegalArgumentException(canAccountMigration.message) - is CanAccountMigration -> throw InternalServerException() - is CircularReferences -> throw IllegalArgumentException(canAccountMigration.message) - is SelfReferences -> throw IllegalArgumentException("Self references are not supported") - is AlsoKnownAsNotFound -> throw IllegalArgumentException(canAccountMigration.message) - is MigrationCoolDown -> throw IllegalArgumentException(canAccountMigration.message) + } else { + when (canAccountMigration) { + is AlreadyMoved -> throw IllegalArgumentException(canAccountMigration.message) + is CanAccountMigration -> throw InternalServerException() + is CircularReferences -> throw IllegalArgumentException(canAccountMigration.message) + is SelfReferences -> throw IllegalArgumentException("Self references are not supported") + is AlsoKnownAsNotFound -> throw IllegalArgumentException(canAccountMigration.message) + is MigrationCoolDown -> throw IllegalArgumentException(canAccountMigration.message) + } } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/application/RegisterApplicationApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/application/RegisterApplicationApplicationService.kt index 10890e85..752b4a78 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/application/RegisterApplicationApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/application/RegisterApplicationApplicationService.kt @@ -91,7 +91,6 @@ class RegisterApplicationApplicationService( ) } - companion object { private val logger = LoggerFactory.getLogger(RegisterApplicationApplicationService::class.java) } 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 94aff5f3..4f4cdf0b 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,15 +36,13 @@ class TimelineRelationshipFollowSubscriber( relationship.targetActorId, Visible.FOLLOWERS ) - ), it.body.principal + ), + it.body.principal ) - - } } companion object { private val logger = LoggerFactory.getLogger(TimelineRelationshipFollowSubscriber::class.java) } - -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/exception/InternalServerException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/exception/InternalServerException.kt index 8acf6a72..20db0f04 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/exception/InternalServerException.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/exception/InternalServerException.kt @@ -11,4 +11,4 @@ class InternalServerException : RuntimeException { enableSuppression, writableStackTrace ) -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/exception/PermissionDeniedException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/exception/PermissionDeniedException.kt index c583ae0b..613609ed 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/exception/PermissionDeniedException.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/exception/PermissionDeniedException.kt @@ -11,4 +11,4 @@ class PermissionDeniedException : RuntimeException { enableSuppression, writableStackTrace ) -} \ No newline at end of file +} 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 8f4a45ec..4baa0ac3 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 @@ -37,7 +37,6 @@ class UserRegisterFilterApplicationService( ) { override suspend fun internalExecute(command: RegisterFilter, principal: LocalUser): Filter { - val filter = dev.usbharu.hideout.core.domain.model.filter.Filter.create( id = FilterId(idGenerateService.generateId()), userDetailId = principal.userDetailId, diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/GetLocalInstanceApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/GetLocalInstanceApplicationService.kt index e0040d91..72c3d5bf 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/GetLocalInstanceApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/GetLocalInstanceApplicationService.kt @@ -16,18 +16,20 @@ class GetLocalInstanceApplicationService( transaction: Transaction ) : AbstractApplicationService( - transaction, logger + transaction, + logger ) { var cachedInstance: Instance? = null override suspend fun internalExecute(command: Unit, principal: Principal): Instance { - if (cachedInstance != null) { return cachedInstance!! } - val instance = (instanceRepository.findByUrl(applicationConfig.url.toURI()) - ?: throw InternalServerException("Local instance not found.")) + val instance = ( + instanceRepository.findByUrl(applicationConfig.url.toURI()) + ?: throw InternalServerException("Local instance not found.") + ) cachedInstance = Instance.of(instance) return cachedInstance!! @@ -36,4 +38,4 @@ class GetLocalInstanceApplicationService( companion object { private val logger = LoggerFactory.getLogger(GetLocalInstanceApplicationService::class.java) } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/Instance.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/Instance.kt index 80adde56..c4853256 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/Instance.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/Instance.kt @@ -7,7 +7,10 @@ data class Instance(val id: Long, val name: String, val url: URI, val descriptio companion object { fun of(instance: Instance): dev.usbharu.hideout.core.application.instance.Instance { return Instance( - instance.id.instanceId, instance.name.name, instance.url, instance.description.description + instance.id.instanceId, + instance.name.name, + instance.url, + instance.description.description ) } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/ActorDetail.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/ActorDetail.kt index 5513227f..b678c549 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/ActorDetail.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/ActorDetail.kt @@ -1,6 +1,5 @@ package dev.usbharu.hideout.core.application.post - import dev.usbharu.hideout.core.domain.model.actor.Actor import dev.usbharu.hideout.core.domain.model.instance.Instance import dev.usbharu.hideout.core.domain.model.media.Media @@ -32,4 +31,4 @@ data class ActorDetail( ) } } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/DeleteLocalPostApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/DeleteLocalPostApplicationService.kt index 00c41804..1de7fe31 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/DeleteLocalPostApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/DeleteLocalPostApplicationService.kt @@ -29,7 +29,8 @@ import org.springframework.stereotype.Service @Service class DeleteLocalPostApplicationService( private val postRepository: PostRepository, - private val actorRepository: ActorRepository, transaction: Transaction, + private val actorRepository: ActorRepository, + transaction: Transaction, ) : LocalUserAbstractApplicationService(transaction, logger) { override suspend fun internalExecute(command: DeleteLocalPost, principal: LocalUser) { diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/GetPostDetailApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/GetPostDetailApplicationService.kt index fcc4ab3d..fef7fd6c 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/GetPostDetailApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/GetPostDetailApplicationService.kt @@ -25,7 +25,8 @@ class GetPostDetailApplicationService( private val mediaRepository: MediaRepository, private val iPostReadAccessControl: IPostReadAccessControl ) : AbstractApplicationService( - transaction, logger + transaction, + logger ) { override suspend fun internalExecute(command: GetPostDetail, principal: Principal): PostDetail { val post = postRepository.findById(PostId(command.postId)) @@ -79,12 +80,15 @@ class GetPostDetailApplicationService( val mediaList = mediaRepository.findByIds(post.mediaIds) return PostDetail.of( - post, first, second, third, mediaList + post, + first, + second, + third, + mediaList ) - } companion object { private val logger = LoggerFactory.getLogger(GetPostDetailApplicationService::class.java) } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/MediaDetail.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/MediaDetail.kt index 3ce780dc..3b99d0d7 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/MediaDetail.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/MediaDetail.kt @@ -25,4 +25,4 @@ data class MediaDetail( ) } } -} \ No newline at end of file +} 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 5a9197ee..2ec51b4b 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 @@ -35,7 +35,6 @@ class UserAcceptFollowRequestApplicationService( ) : LocalUserAbstractApplicationService(transaction, logger) { override suspend fun internalExecute(command: AcceptFollowRequest, principal: LocalUser) { - val actor = actorRepository.findById(principal.actorId) ?: throw InternalServerException("Actor ${principal.actorId} not found") 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 62924469..0dd1e686 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 @@ -36,8 +36,6 @@ class UserBlockApplicationService( ) : LocalUserAbstractApplicationService(transaction, logger) { override suspend fun internalExecute(command: Block, principal: LocalUser) { - - val actor = actorRepository.findById(principal.actorId) ?: throw IllegalStateException("Actor ${principal.actorId} not found") 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 e863befd..bbecd56d 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 @@ -46,14 +46,14 @@ class GetRelationshipApplicationService( val target = actorRepository.findById(targetId) ?: throw IllegalArgumentException("Actor ${command.targetActorId} not found.") val relationship = ( - relationshipRepository.findByActorIdAndTargetId(actor.id, targetId) - ?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(actor.id, targetId) - ) + relationshipRepository.findByActorIdAndTargetId(actor.id, targetId) + ?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(actor.id, targetId) + ) val relationship1 = ( - relationshipRepository.findByActorIdAndTargetId(targetId, actor.id) - ?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(targetId, actor.id) - ) + relationshipRepository.findByActorIdAndTargetId(targetId, actor.id) + ?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(targetId, actor.id) + ) val actorInstanceRelationship = actorInstanceRelationshipRepository.findByActorIdAndInstanceId(actor.id, target.instance) 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 index 8c4eb0bc..bd8d26a3 100644 --- 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 @@ -15,4 +15,4 @@ abstract class LocalUserAbstractApplicationService(transaction: Tran } protected abstract suspend fun internalExecute(command: T, principal: LocalUser): 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 b0ea5580..3809fb3a 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 @@ -13,7 +13,8 @@ class UserAddTimelineRelationshipApplicationService( transaction: Transaction ) : LocalUserAbstractApplicationService( - transaction, logger + transaction, + logger ) { override suspend fun internalExecute(command: AddTimelineRelationship, principal: LocalUser) { timelineRelationshipRepository.save(command.timelineRelationship) @@ -22,4 +23,4 @@ class UserAddTimelineRelationshipApplicationService( companion object { private val logger = LoggerFactory.getLogger(UserAddTimelineRelationshipApplicationService::class.java) } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/ApplicationConfig.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/ApplicationConfig.kt index bbc461ec..5cb5941c 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/ApplicationConfig.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/ApplicationConfig.kt @@ -24,4 +24,4 @@ data class ApplicationConfig( val url: URL, val private: Boolean = true, val keySize: Int = 2048, -) \ No newline at end of file +) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/filter/Filter.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/filter/Filter.kt index 9a41fa9e..e80eece0 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/filter/Filter.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/filter/Filter.kt @@ -69,7 +69,6 @@ class Filter( return id.hashCode() } - companion object { fun isAllow(user: UserDetail, action: Action, resource: Filter): Boolean { return when (action) { diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/Post.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/Post.kt index 9a578c79..247067a1 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/Post.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/Post.kt @@ -241,25 +241,25 @@ class Post( override fun toString(): String { return "Post(" + - "id=$id, " + - "createdAt=$createdAt, " + - "url=$url, " + - "repostId=$repostId, " + - "replyId=$replyId, " + - "apId=$apId, " + - "actorId=$actorId, " + - "visibility=$visibility, " + - "visibleActors=$visibleActors, " + - "content=$content, " + - "overview=$overview, " + - "sensitive=$sensitive, " + - "text='$text', " + - "emojiIds=$emojiIds, " + - "mediaIds=$mediaIds, " + - "deleted=$deleted, " + - "hide=$hide, " + - "moveTo=$moveTo" + - ")" + "id=$id, " + + "createdAt=$createdAt, " + + "url=$url, " + + "repostId=$repostId, " + + "replyId=$replyId, " + + "apId=$apId, " + + "actorId=$actorId, " + + "visibility=$visibility, " + + "visibleActors=$visibleActors, " + + "content=$content, " + + "overview=$overview, " + + "sensitive=$sensitive, " + + "text='$text', " + + "emojiIds=$emojiIds, " + + "mediaIds=$mediaIds, " + + "deleted=$deleted, " + + "hide=$hide, " + + "moveTo=$moveTo" + + ")" } companion object { @@ -315,6 +315,5 @@ class Post( post.addDomainEvent(PostDomainEventFactory(post).createEvent(PostEvent.CREATE)) return post } - } } 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 index 9bcc6cbb..56fbe4c5 100644 --- 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 @@ -2,4 +2,4 @@ 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 +data object Anonymous : Principal(ActorId.ghost, null, null) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/LocalUser.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/LocalUser.kt index afe7334e..a29abe6f 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/LocalUser.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/LocalUser.kt @@ -12,4 +12,4 @@ class LocalUser( 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 index 6e7b939f..1a0cf076 100644 --- 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 @@ -4,4 +4,4 @@ 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 +sealed class Principal(open val actorId: ActorId, open val userDetailId: UserDetailId?, open val acct: Acct?) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/PrincipalContextHolder.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/PrincipalContextHolder.kt index 464363ce..1bf8f653 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/PrincipalContextHolder.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/support/principal/PrincipalContextHolder.kt @@ -2,4 +2,4 @@ package dev.usbharu.hideout.core.domain.model.support.principal interface PrincipalContextHolder { suspend fun getPrincipal(): Principal -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/timelineobject/TimelineObject.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/timelineobject/TimelineObject.kt index 171fcc01..636d8bcb 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/timelineobject/TimelineObject.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/timelineobject/TimelineObject.kt @@ -33,7 +33,7 @@ class TimelineObject( lastUpdatedAt: Instant, var warnFilters: List, - ) { +) { var isPureRepost = isPureRepost private set var visibleActors = visibleActors @@ -125,9 +125,9 @@ class TimelineObject( repostActorId = repost.actorId, visibility = post.visibility, isPureRepost = repost.mediaIds.isEmpty() && - repost.overview == null && - repost.content == PostContent.empty && - repost.replyId == null, + repost.overview == null && + repost.content == PostContent.empty && + repost.replyId == null, mediaIds = post.mediaIds, emojiIds = post.emojiIds, visibleActors = post.visibleActors.toList(), diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/service/post/DefaultPostReadAccessControl.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/service/post/DefaultPostReadAccessControl.kt index b7274df9..c0466054 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/service/post/DefaultPostReadAccessControl.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/service/post/DefaultPostReadAccessControl.kt @@ -16,36 +16,37 @@ interface IPostReadAccessControl { class DefaultPostReadAccessControl(private val relationshipRepository: RelationshipRepository) : IPostReadAccessControl { override suspend fun isAllow(post: Post, principal: Principal): Boolean { - - //ポスト主は無条件で見れる + // ポスト主は無条件で見れる if (post.actorId == principal.actorId) { return true } - val relationship = (relationshipRepository.findByActorIdAndTargetId(post.actorId, principal.actorId) - ?: Relationship.default(post.actorId, principal.actorId)) + val relationship = ( + relationshipRepository.findByActorIdAndTargetId(post.actorId, principal.actorId) + ?: Relationship.default(post.actorId, principal.actorId) + ) - //ブロックされてたら見れない + // ブロックされてたら見れない if (relationship.blocking) { return false } - //PublicかUnlistedなら見れる + // PublicかUnlistedなら見れる if (post.visibility == Visibility.PUBLIC || post.visibility == Visibility.UNLISTED) { return true } - //principalがAnonymousなら見れない + // principalがAnonymousなら見れない if (principal is Anonymous) { return false } - //DirectでvisibleActorsに含まれていたら見れる + // DirectでvisibleActorsに含まれていたら見れる if (post.visibility == Visibility.DIRECT && post.visibleActors.contains(principal.actorId)) { return true } - //Followersでフォロワーなら見れる + // Followersでフォロワーなら見れる if (post.visibility == Visibility.FOLLOWERS) { val inverseRelationship = relationshipRepository.findByActorIdAndTargetId(principal.actorId, post.actorId) ?: return false @@ -53,8 +54,7 @@ class DefaultPostReadAccessControl(private val relationshipRepository: Relations return inverseRelationship.following } - //その他の場合は見れない + // その他の場合は見れない return false } - -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/ExposedPrincipalQueryService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/ExposedPrincipalQueryService.kt index 413ccc67..742956ac 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/ExposedPrincipalQueryService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/ExposedPrincipalQueryService.kt @@ -34,4 +34,4 @@ class ExposedPrincipalQueryService : PrincipalQueryService, AbstractRepository() companion object { private val logger: Logger = LoggerFactory.getLogger(ExposedPrincipalQueryService::class.java) } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/SpringSecurityFormLoginPrincipalContextHolder.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/SpringSecurityFormLoginPrincipalContextHolder.kt index 32ca47c4..a2b466c1 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/SpringSecurityFormLoginPrincipalContextHolder.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/SpringSecurityFormLoginPrincipalContextHolder.kt @@ -22,7 +22,6 @@ class SpringSecurityFormLoginPrincipalContextHolder( SecurityContextHolder.getContext().authentication?.principal as? HideoutUserDetails ?: return Anonymous return transaction.transaction { - val userDetail = principalQueryService.findByUserDetailId(UserDetailId(hideoutUserDetails.userDetailsId)) LocalUser( userDetail.actorId, @@ -30,6 +29,5 @@ class SpringSecurityFormLoginPrincipalContextHolder( Acct(userDetail.username, userDetail.host) ) } - } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/SpringSecurityOauth2PrincipalContextHolder.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/SpringSecurityOauth2PrincipalContextHolder.kt index 95984983..eefb47b1 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/SpringSecurityOauth2PrincipalContextHolder.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/SpringSecurityOauth2PrincipalContextHolder.kt @@ -33,4 +33,4 @@ class SpringSecurityOauth2PrincipalContextHolder( ) } } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/InternalTimelineObjectRepository.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/InternalTimelineObjectRepository.kt index 490be0ab..3f26cbab 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/InternalTimelineObjectRepository.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/timeline/InternalTimelineObjectRepository.kt @@ -30,4 +30,4 @@ data class InternalTimelineObjectOption( val localOnly: Boolean? = null, val remoteOnly: Boolean? = null, val mediaOnly: Boolean? = null -) \ No newline at end of file +) 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 8872d60d..b19f3c4a 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 @@ -38,7 +38,8 @@ class AuthController( suspend fun signUp(@Validated @ModelAttribute signUpForm: SignUpForm, request: HttpServletRequest): String { val registerLocalActor = RegisterLocalActor(signUpForm.username, signUpForm.password) val uri = registerLocalActorApplicationService.execute( - registerLocalActor, Anonymous + registerLocalActor, + Anonymous ) request.login(signUpForm.username, signUpForm.password) return "redirect:$uri" diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/media/LocalFileController.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/media/LocalFileController.kt index cb003b77..f02dc15f 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/media/LocalFileController.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/media/LocalFileController.kt @@ -30,7 +30,6 @@ import org.springframework.web.bind.annotation.PathVariable import java.nio.file.Path import kotlin.io.path.name - @Controller @ConditionalOnProperty("hideout.storage.type", havingValue = "local", matchIfMissing = true) class LocalFileController( @@ -64,4 +63,4 @@ class LocalFileController( .contentLength(pathResource.contentLength()) .body(pathResource) } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/posts/PostsController.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/posts/PostsController.kt index 7395bfc7..4dda4759 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/posts/PostsController.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/posts/PostsController.kt @@ -31,4 +31,4 @@ class PostsController( return "postById" } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/posts/PublishController.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/posts/PublishController.kt index 2c472bf5..76f4ad00 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/posts/PublishController.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/posts/PublishController.kt @@ -55,6 +55,6 @@ class PublishController( ) val id = userRegisterLocalPostApplicationService.execute(command, principal) - return "redirect:/users/${principal.acct?.userpart}/posts/${id}" + return "redirect:/users/${principal.acct?.userpart}/posts/$id" } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/query/principal/PrincipalDTO.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/query/principal/PrincipalDTO.kt index 40b0cb90..4861b80a 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/query/principal/PrincipalDTO.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/query/principal/PrincipalDTO.kt @@ -3,4 +3,4 @@ package dev.usbharu.hideout.core.query.principal import dev.usbharu.hideout.core.domain.model.actor.ActorId import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId -data class PrincipalDTO(val userDetailId: UserDetailId, val actorId: ActorId, val username: String, val host: String) \ No newline at end of file +data class PrincipalDTO(val userDetailId: UserDetailId, val actorId: ActorId, val username: String, val host: String) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/query/principal/PrincipalQueryService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/query/principal/PrincipalQueryService.kt index 3aa01531..49a0fc1d 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/query/principal/PrincipalQueryService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/query/principal/PrincipalQueryService.kt @@ -4,4 +4,4 @@ import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId interface PrincipalQueryService { suspend fun findByUserDetailId(userDetailId: UserDetailId): PrincipalDTO -} \ No newline at end of file +}