diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/UserDetail.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/UserDetail.kt index 6e066e3f..5b363296 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/UserDetail.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/actor/UserDetail.kt @@ -47,23 +47,23 @@ data class UserDetail( customEmojis: List, ): dev.usbharu.hideout.core.application.actor.UserDetail { return UserDetail( - actor.id.id, - userDetail.id.id, - actor.name.name, - actor.domain.domain, - actor.screenName.screenName, - actor.url.toString(), - actor.url.toString(), - actor.description.description, - actor.locked, - customEmojis, - actor.createdAt, - actor.lastPostAt, - actor.postsCount.postsCount, - actor.followingCount?.relationshipCount, - actor.followersCount?.relationshipCount, - actor.moveTo?.id, - actor.suspend + id = actor.id.id, + userDetailId = userDetail.id.id, + name = actor.name.name, + domain = actor.domain.domain, + screenName = actor.screenName.screenName, + url = actor.url.toString(), + iconUrl = actor.url.toString(), + description = actor.description.description, + locked = actor.locked, + emojis = customEmojis, + createdAt = actor.createdAt, + lastPostAt = actor.lastPostAt, + postsCount = actor.postsCount.postsCount, + followingCount = actor.followingCount?.relationshipCount, + followersCount = actor.followersCount?.relationshipCount, + moveTo = actor.moveTo?.id, + suspend = actor.suspend ) } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/Filter.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/Filter.kt index 0231663e..e482991a 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/Filter.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/filter/Filter.kt @@ -46,4 +46,4 @@ data class Filter( ) } } -} \ No newline at end of file +} 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 3b032fc4..2e28d5d0 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 @@ -27,7 +27,8 @@ import org.springframework.stereotype.Service @Service class UserDeleteFilterApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) : AbstractApplicationService( - transaction, logger + transaction, + logger ) { companion object { private val logger = LoggerFactory.getLogger(UserDeleteFilterApplicationService::class.java) @@ -37,4 +38,4 @@ class UserDeleteFilterApplicationService(private val filterRepository: FilterRep val filter = filterRepository.findByFilterId(FilterId(command.filterId)) ?: throw Exception("not found") filterRepository.delete(filter) } -} \ No newline at end of file +} 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 bf10cc6b..0ecf97f8 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 @@ -27,7 +27,8 @@ import org.springframework.stereotype.Service @Service class UserGetFilterApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) : AbstractApplicationService( - transaction, logger + transaction, + logger ) { override suspend fun internalExecute(command: GetFilter, executor: CommandExecutor): Filter { val filter = filterRepository.findByFilterId(FilterId(command.filterId)) ?: throw Exception("Not Found") @@ -38,4 +39,4 @@ class UserGetFilterApplicationService(private val filterRepository: FilterReposi companion object { private val logger = LoggerFactory.getLogger(UserGetFilterApplicationService::class.java) } -} \ 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 a1dc48a3..ac7a1309 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 @@ -34,7 +34,8 @@ class UserRegisterFilterApplicationService( transaction: Transaction, ) : AbstractApplicationService( - transaction, logger + transaction, + logger ) { companion object { @@ -44,14 +45,13 @@ class UserRegisterFilterApplicationService( override suspend fun internalExecute(command: RegisterFilter, executor: CommandExecutor): Filter { require(executor is UserDetailGettableCommandExecutor) - val filter = dev.usbharu.hideout.core.domain.model.filter.Filter.create( - FilterId(idGenerateService.generateId()), - UserDetailId(executor.userDetailId), - FilterName(command.filterName), - command.filterContext, - command.filterAction, - command.filterKeywords + id = FilterId(idGenerateService.generateId()), + userDetailId = UserDetailId(executor.userDetailId), + name = FilterName(command.filterName), + filterContext = command.filterContext, + filterAction = command.filterAction, + filterKeywords = command.filterKeywords .map { FilterKeyword( FilterKeywordId(idGenerateService.generateId()), @@ -64,4 +64,4 @@ class UserRegisterFilterApplicationService( filterRepository.save(filter) return Filter.of(filter) } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/InitLocalInstanceApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/InitLocalInstanceApplicationService.kt index 0a8a6e98..77d2e41b 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/InitLocalInstanceApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/InitLocalInstanceApplicationService.kt @@ -40,18 +40,18 @@ class InitLocalInstanceApplicationService( if (findByUrl == null) { val instance = Instance( - InstanceId(idGenerateService.generateId()), - InstanceName(applicationConfig.url.host), - InstanceDescription(""), - applicationConfig.url.toURI(), - applicationConfig.url.toURI(), - null, - InstanceSoftware("hideout"), - InstanceVersion(buildProperties.version), - false, - false, - InstanceModerationNote(""), - Instant.now(), + id = InstanceId(idGenerateService.generateId()), + name = InstanceName(applicationConfig.url.host), + description = InstanceDescription(""), + url = applicationConfig.url.toURI(), + iconUrl = applicationConfig.url.toURI(), + sharedInbox = null, + software = InstanceSoftware("hideout"), + version = InstanceVersion(buildProperties.version), + isBlocked = false, + isMuted = false, + moderationNote = InstanceModerationNote(""), + createdAt = Instant.now(), ) instanceRepository.save(instance) } 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 1ba8034a..e3ba618e 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 @@ -36,7 +36,8 @@ class UploadMediaApplicationService( private val idGenerateService: IdGenerateService, transaction: Transaction ) : AbstractApplicationService( - transaction, logger + transaction, + logger ) { companion object { private val logger = LoggerFactory.getLogger(UploadMediaApplicationService::class.java) @@ -53,20 +54,19 @@ class UploadMediaApplicationService( val uri = mediaStore.upload(process.path, "$id.${process.mimeType.subtype}") val media = MediaModel( - MediaId(id), - MediaName(command.name), - uri, - command.remoteUri, - thumbnailUri, - process.fileType, - process.mimeType, - process.blurHash?.let { MediaBlurHash(it) }, - command.description?.let { MediaDescription(it) } + id = MediaId(id), + name = MediaName(command.name), + url = uri, + remoteUrl = command.remoteUri, + thumbnailUrl = thumbnailUri, + type = process.fileType, + mimeType = process.mimeType, + blurHash = process.blurHash?.let { MediaBlurHash(it) }, + description = command.description?.let { MediaDescription(it) } ) mediaRepository.save(media) return Media.of(media) - } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/Post.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/Post.kt index 538b8911..2ed11666 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/Post.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/Post.kt @@ -39,19 +39,19 @@ data class Post( companion object { fun of(post: Post): dev.usbharu.hideout.core.application.post.Post { return Post( - post.id.id, - post.actorId.id, - post.overview?.overview, - post.text, - post.content.content, - post.createdAt, - post.visibility, - post.url, - post.repostId?.id, - post.replyId?.id, - post.sensitive, - post.mediaIds.map { it.id }, - post.moveTo?.id + id = post.id.id, + actorId = post.actorId.id, + overview = post.overview?.overview, + text = post.text, + content = post.content.content, + createdAt = post.createdAt, + visibility = post.visibility, + url = post.url, + repostId = post.repostId?.id, + replyId = post.replyId?.id, + sensitive = post.sensitive, + mediaIds = post.mediaIds.map { it.id }, + moveTo = post.moveTo?.id ) } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/get/Relationship.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/get/Relationship.kt index b14c78fd..4893d62a 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/get/Relationship.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/relationship/get/Relationship.kt @@ -40,18 +40,18 @@ data class Relationship( actorInstanceRelationship: ActorInstanceRelationship, ): dev.usbharu.hideout.core.application.relationship.get.Relationship { return Relationship( - relationship.actorId.id, - relationship.targetActorId.id, - relationship.following, - relationship2.following, - relationship.blocking, - relationship2.blocking, - relationship.muting, - relationship.followRequesting, - relationship2.followRequesting, - actorInstanceRelationship.isBlocking(), - actorInstanceRelationship.isMuting(), - actorInstanceRelationship.isDoNotSendPrivate() + actorId = relationship.actorId.id, + targetId = relationship.targetActorId.id, + following = relationship.following, + followedBy = relationship2.following, + blocking = relationship.blocking, + blockedBy = relationship2.blocking, + muting = relationship.muting, + followRequesting = relationship.followRequesting, + followRequestedBy = relationship2.followRequesting, + domainBlocking = actorInstanceRelationship.isBlocking(), + domainMuting = actorInstanceRelationship.isMuting(), + domainDoNotSendPrivate = actorInstanceRelationship.isDoNotSendPrivate() ) } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/FFmpegVideoConfig.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/FFmpegVideoConfig.kt index 6f19a56b..65e5f9be 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/FFmpegVideoConfig.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/FFmpegVideoConfig.kt @@ -14,4 +14,4 @@ data class FFmpegVideoConfig( val videoQuality: Double = 1.0, val videoOption: List = listOf("preset", "ultrafast"), val maxBitrate: Int = 1300000, -) \ No newline at end of file +) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/LocalStorageConfig.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/LocalStorageConfig.kt index a5cfc2e8..48962c11 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/LocalStorageConfig.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/LocalStorageConfig.kt @@ -14,4 +14,4 @@ import org.springframework.boot.context.properties.ConfigurationProperties data class LocalStorageConfig( val path: String = "files", val publicUrl: String? -) \ No newline at end of file +) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/S3StorageConfig.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/S3StorageConfig.kt index fa523441..1a8b5677 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/S3StorageConfig.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/S3StorageConfig.kt @@ -31,4 +31,4 @@ class AwsConfig { .credentialsProvider { AwsBasicCredentials.create(awsConfig.accessKey, awsConfig.secretKey) } .build() } -} \ No newline at end of file +} 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 a03f92e6..69e154eb 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 @@ -37,10 +37,10 @@ class ActorEventBody(actor: Actor) : DomainEventBody( ) enum class ActorEvent(val eventName: String, val collectable: Boolean = true) { - update("ActorUpdate"), - delete("ActorDelete"), - checkUpdate("ActorCheckUpdate"), - move("ActorMove"), - actorSuspend("ActorSuspend"), - actorUnsuspend("ActorUnsuspend"), + UPDATE("ActorUpdate"), + DELETE("ActorDelete"), + CHECK_UPDATE("ActorCheckUpdate"), + MOVE("ActorMove"), + ACTOR_SUSPEND("ActorSuspend"), + ACTOR_UNSUSPEND("ActorUnsuspend"), } 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 c5c6daf7..5ff3fc5f 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 @@ -41,7 +41,7 @@ class ActorInstanceRelationshipEventBody(actorInstanceRelationship: ActorInstanc ) enum class ActorInstanceRelationshipEvent(val eventName: String) { - block("ActorInstanceBlock"), - mute("ActorInstanceMute"), - unmute("ActorInstanceUnmute"), + BLOCK("ActorInstanceBlock"), + MUTE("ActorInstanceMute"), + UNMUTE("ActorInstanceUnmute"), } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/instance/InstanceEvent.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/instance/InstanceEvent.kt index 276d2f75..72f0941a 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/instance/InstanceEvent.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/instance/InstanceEvent.kt @@ -32,5 +32,5 @@ class InstanceEventFactory(private val instance: Instance) { class InstanceEventBody(instance: Instance) : DomainEventBody(mapOf("instance" to instance)) enum class InstanceEvent(val eventName: String) { - update("InstanceUpdate") + UPDATE("InstanceUpdate") } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/post/PostEvent.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/post/PostEvent.kt index ad0fd36f..5020d056 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/post/PostEvent.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/event/post/PostEvent.kt @@ -33,8 +33,8 @@ class PostDomainEventFactory(private val post: Post, private val actor: Actor? = class PostEventBody(post: Post, actor: Actor?) : DomainEventBody(mapOf("post" to post, "actor" to actor)) enum class PostEvent(val eventName: String) { - delete("PostDelete"), - update("PostUpdate"), - create("PostCreate"), - checkUpdate("PostCheckUpdate"), + DELETE("PostDelete"), + UPDATE("PostUpdate"), + CREATE("PostCreate"), + CHECK_UPDATE("PostCheckUpdate"), } 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 38183454..89adf3e8 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 @@ -29,12 +29,12 @@ class RelationshipEventFactory(private val relationship: Relationship) { class RelationshipEventBody(relationship: Relationship) : DomainEventBody(mapOf("relationship" to relationship)) enum class RelationshipEvent(val eventName: String) { - follow("RelationshipFollow"), - unfollow("RelationshipUnfollow"), - block("RelationshipBlock"), - unblock("RelationshipUnblock"), - mute("RelationshipMute"), - unmute("RelationshipUnmute"), - followRequest("RelationshipFollowRequest"), - unfollowRequest("RelationshipUnfollowRequest"), + FOLLOW("RelationshipFollow"), + UNFOLLOW("RelationshipUnfollow"), + BLOCK("RelationshipBlock"), + UNBLOCK("RelationshipUnblock"), + MUTE("RelationshipMute"), + UNMUTE("RelationshipUnmute"), + FOLLOW_REQUEST("RelationshipFollowRequest"), + UNFOLLOW_REQUEST("RelationshipUnfollowRequest"), } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt index 73f5d15c..45d34c4d 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt @@ -26,6 +26,7 @@ import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable import java.net.URI import java.time.Instant +@Suppress("LongParameterList") class Actor( val id: ActorId, val name: ActorName, @@ -62,7 +63,7 @@ class Actor( private set fun setBannerUrl(banner: MediaId?, actor: Actor) { - addDomainEvent(ActorDomainEventFactory(this).createEvent(update)) + addDomainEvent(ActorDomainEventFactory(this).createEvent(UPDATE)) this.banner = banner } @@ -70,7 +71,7 @@ class Actor( private set fun setIconUrl(icon: MediaId?, actor: Actor) { - addDomainEvent(ActorDomainEventFactory(this).createEvent(update)) + addDomainEvent(ActorDomainEventFactory(this).createEvent(UPDATE)) this.icon = icon } @@ -86,9 +87,9 @@ class Actor( var suspend = suspend set(value) { if (field != value && value) { - addDomainEvent(ActorDomainEventFactory(this).createEvent(actorSuspend)) + addDomainEvent(ActorDomainEventFactory(this).createEvent(ACTOR_SUSPEND)) } else if (field != value && !value) { - addDomainEvent(ActorDomainEventFactory(this).createEvent(actorUnsuspend)) + addDomainEvent(ActorDomainEventFactory(this).createEvent(ACTOR_UNSUSPEND)) } field = value } @@ -102,7 +103,7 @@ class Actor( var moveTo = moveTo set(value) { require(value != id) - addDomainEvent(ActorDomainEventFactory(this).createEvent(move)) + addDomainEvent(ActorDomainEventFactory(this).createEvent(MOVE)) field = value } @@ -111,12 +112,12 @@ class Actor( var description = description set(value) { - addDomainEvent(ActorDomainEventFactory(this).createEvent(update)) + addDomainEvent(ActorDomainEventFactory(this).createEvent(UPDATE)) field = value } var screenName = screenName set(value) { - addDomainEvent(ActorDomainEventFactory(this).createEvent(update)) + addDomainEvent(ActorDomainEventFactory(this).createEvent(UPDATE)) field = value } @@ -125,7 +126,7 @@ class Actor( fun delete() { if (deleted.not()) { - addDomainEvent(ActorDomainEventFactory(this).createEvent(delete)) + addDomainEvent(ActorDomainEventFactory(this).createEvent(DELETE)) screenName = ActorScreenName.empty description = ActorDescription.empty emojis = emptySet() @@ -142,6 +143,6 @@ class Actor( } fun checkUpdate() { - addDomainEvent(ActorDomainEventFactory(this).createEvent(checkUpdate)) + addDomainEvent(ActorDomainEventFactory(this).createEvent(CHECK_UPDATE)) } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actorinstancerelationship/ActorInstanceRelationship.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actorinstancerelationship/ActorInstanceRelationship.kt index 3cef6c86..f4244ca5 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actorinstancerelationship/ActorInstanceRelationship.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actorinstancerelationship/ActorInstanceRelationship.kt @@ -30,7 +30,7 @@ data class ActorInstanceRelationship( private var doNotSendPrivate: Boolean = false, ) : DomainEventStorable() { fun block(): ActorInstanceRelationship { - addDomainEvent(ActorInstanceRelationshipDomainEventFactory(this).createEvent(block)) + addDomainEvent(ActorInstanceRelationshipDomainEventFactory(this).createEvent(BLOCK)) blocking = true return this } @@ -41,13 +41,13 @@ data class ActorInstanceRelationship( } fun mute(): ActorInstanceRelationship { - addDomainEvent(ActorInstanceRelationshipDomainEventFactory(this).createEvent(mute)) + addDomainEvent(ActorInstanceRelationshipDomainEventFactory(this).createEvent(MUTE)) muting = true return this } fun unmute(): ActorInstanceRelationship { - addDomainEvent(ActorInstanceRelationshipDomainEventFactory(this).createEvent(unmute)) + addDomainEvent(ActorInstanceRelationshipDomainEventFactory(this).createEvent(UNMUTE)) muting = false return this } 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 e174ec3b..41a835b3 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 @@ -41,12 +41,12 @@ class Filter( fun reconstructWith(filterKeywords: Set): Filter { return Filter( - this.id, - this.userDetailId, - this.name, - this.filterContext, - this.filterAction, - filterKeywords + id = this.id, + userDetailId = this.userDetailId, + name = this.name, + filterContext = this.filterContext, + filterAction = this.filterAction, + filterKeywords = filterKeywords ) } @@ -61,6 +61,7 @@ class Filter( SET_KEYWORDS } + @Suppress("LongParameterList") fun create( id: FilterId, userDetailId: UserDetailId, diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/filter/FilterAction.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/filter/FilterAction.kt index ac3e8b88..d19c8db8 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/filter/FilterAction.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/filter/FilterAction.kt @@ -1,6 +1,6 @@ package dev.usbharu.hideout.core.domain.model.filter enum class FilterAction { - warn, - hide + WARN, + HIDE } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/filter/FilterContext.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/filter/FilterContext.kt index 418f9573..df987e3d 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/filter/FilterContext.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/filter/FilterContext.kt @@ -1,9 +1,9 @@ package dev.usbharu.hideout.core.domain.model.filter enum class FilterContext { - home, - notifications, - public, - thread, - account + HOME, + NOTIFICATION, + PUBLIC, + THREAD, + ACCOUNT } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Instance.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Instance.kt index 28e1f6d4..4bda1989 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Instance.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/instance/Instance.kt @@ -22,6 +22,7 @@ import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable import java.net.URI import java.time.Instant +@Suppress("LongParameterList") class Instance( val id: InstanceId, var name: InstanceName, @@ -39,7 +40,7 @@ class Instance( var iconUrl = iconUrl set(value) { - addDomainEvent(InstanceEventFactory(this).createEvent(InstanceEvent.update)) + addDomainEvent(InstanceEventFactory(this).createEvent(InstanceEvent.UPDATE)) field = value } 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 db7f1693..9bf9211c 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 @@ -28,6 +28,7 @@ import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable import java.net.URI import java.time.Instant +@Suppress("LongParameterList", "TooManyFunctions") class Post( val id: PostId, actorId: ActorId, @@ -67,7 +68,7 @@ class Post( require(deleted.not()) if (this.visibility != visibility) { - addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.update)) + addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE)) } this.visibility = visibility } @@ -79,7 +80,7 @@ class Post( require(isAllow(actor, UPDATE, this)) require(deleted.not()) if (visibility == Visibility.DIRECT) { - addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.update)) + addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE)) this.visibleActors = this.visibleActors.plus(visibleActors) } } @@ -97,7 +98,7 @@ class Post( require(isAllow(actor, UPDATE, this)) require(deleted.not()) if (this.content != content) { - addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.update)) + addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE)) } this.content = content } @@ -115,7 +116,7 @@ class Post( require(isAllow(actor, UPDATE, this)) require(deleted.not()) if (this.overview != overview) { - addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.update)) + addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE)) } this.overview = overview } @@ -127,7 +128,7 @@ class Post( isAllow(actor, UPDATE, this) require(deleted.not()) if (this.sensitive != sensitive) { - addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.update)) + addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE)) } this.sensitive = sensitive } @@ -160,7 +161,7 @@ class Post( fun addMediaIds(mediaIds: List, actor: Actor) { require(isAllow(actor, UPDATE, this)) require(deleted.not()) - addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.update)) + addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE)) this.mediaIds = this.mediaIds.plus(mediaIds).distinct() } @@ -170,7 +171,7 @@ class Post( fun delete(actor: Actor) { isAllow(actor, DELETE, this) if (deleted.not()) { - addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.delete)) + addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.DELETE)) content = PostContent.empty overview = null mediaIds = emptyList() @@ -179,7 +180,7 @@ class Post( } fun checkUpdate() { - addDomainEvent(PostDomainEventFactory(this).createEvent(PostEvent.checkUpdate)) + addDomainEvent(PostDomainEventFactory(this).createEvent(PostEvent.CHECK_UPDATE)) } fun restore(content: PostContent, overview: PostOverview?, mediaIds: List) { @@ -219,9 +220,7 @@ class Post( return id == other.id } - override fun hashCode(): Int { - return id.hashCode() - } + override fun hashCode(): Int = id.hashCode() fun reconstructWith(mediaIds: List, emojis: List, visibleActors: Set): Post { return Post( @@ -245,6 +244,7 @@ class Post( } companion object { + @Suppress("LongParameterList") fun create( id: PostId, actorId: ActorId, @@ -274,24 +274,24 @@ class Post( } val post = Post( - id, - actorId, - overview, - content, - createdAt, - visibility1, - url, - repostId, - replyId, - sensitive, - apId, - deleted, - mediaIds, - visibleActors, - hide, - moveTo + id = id, + actorId = actorId, + overview = overview, + content = content, + createdAt = createdAt, + visibility = visibility1, + url = url, + repostId = repostId, + replyId = replyId, + sensitive = sensitive, + apId = apId, + deleted = deleted, + mediaIds = mediaIds, + visibleActors = visibleActors, + hide = hide, + moveTo = moveTo ) - post.addDomainEvent(PostDomainEventFactory(post).createEvent(PostEvent.create)) + post.addDomainEvent(PostDomainEventFactory(post).createEvent(PostEvent.CREATE)) return post } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/PostContent.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/PostContent.kt index d8e0a18d..2d787e75 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/PostContent.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/PostContent.kt @@ -22,7 +22,7 @@ data class PostContent(val text: String, val content: String, val emojiIds: List companion object { val empty = PostContent("", "", emptyList()) - val contentLength = 5000 - val textLength = 3000 + const val CONTENT_LENGTH = 5000 + const val TEXT_LENGTH = 3000 } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/PostOverview.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/PostOverview.kt index 1c2419bb..0793febe 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/PostOverview.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/post/PostOverview.kt @@ -19,6 +19,6 @@ package dev.usbharu.hideout.core.domain.model.post @JvmInline value class PostOverview(val overview: String) { companion object { - val length = 100 + const val LENGTH = 100 } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/relationship/Relationship.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/relationship/Relationship.kt index e4893712..068de901 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/relationship/Relationship.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/relationship/Relationship.kt @@ -46,33 +46,33 @@ class Relationship( fun follow() { require(blocking.not()) following = true - addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.follow)) + addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.FOLLOW)) } fun unfollow() { following = false - addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.unfollow)) + addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.UNFOLLOW)) } fun block() { require(following.not()) blocking = true - addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.block)) + addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.BLOCK)) } fun unblock() { blocking = false - addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.unblock)) + addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.UNBLOCK)) } fun mute() { muting = true - addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.mute)) + addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.MUTE)) } fun unmute() { muting = false - addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.unmute)) + addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.UNMUTE)) } fun muteFollowRequest() { @@ -86,12 +86,12 @@ class Relationship( fun followRequest() { require(blocking.not()) followRequesting = true - addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.followRequest)) + addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.FOLLOW_REQUEST)) } fun unfollowRequest() { followRequesting = false - addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.unfollowRequest)) + addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.UNFOLLOW_REQUEST)) } fun acceptFollowRequest() { diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/shared/Domain.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/shared/Domain.kt index 963c2574..cf6f9f1b 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/shared/Domain.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/shared/Domain.kt @@ -19,10 +19,10 @@ package dev.usbharu.hideout.core.domain.model.shared @JvmInline value class Domain(val domain: String) { init { - require(domain.length <= length) + require(domain.length <= LENGTH) } companion object { - val length = 1000 + const val LENGTH = 1000 } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/userdetails/UserDetail.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/userdetails/UserDetail.kt index 52016f71..e41a86b8 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/userdetails/UserDetail.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/userdetails/UserDetail.kt @@ -27,6 +27,17 @@ class UserDetail private constructor( var lastMigration: Instant? = null, ) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as UserDetail + + return id == other.id + } + + override fun hashCode(): Int = id.hashCode() + companion object { fun create( id: UserDetailId, @@ -44,17 +55,4 @@ class UserDetail private constructor( ) } } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - - other as UserDetail - - return id == other.id - } - - override fun hashCode(): Int { - return id.hashCode() - } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/shared/domainevent/DomainEvent.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/shared/domainevent/DomainEvent.kt index a30cb94c..d4379335 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/shared/domainevent/DomainEvent.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/shared/domainevent/DomainEvent.kt @@ -36,9 +36,8 @@ data class DomainEvent( val collectable: Boolean = false ) { companion object { - fun create(name: String, body: DomainEventBody, collectable: Boolean = false): DomainEvent { - return DomainEvent(UUID.randomUUID().toString(), name, Instant.now(), body, collectable) - } + fun create(name: String, body: DomainEventBody, collectable: Boolean = false): DomainEvent = + DomainEvent(UUID.randomUUID().toString(), name, Instant.now(), body, collectable) fun reconstruct( id: String, @@ -46,8 +45,6 @@ data class DomainEvent( occurredOn: Instant, body: DomainEventBody, collectable: Boolean - ): DomainEvent { - return DomainEvent(id, name, occurredOn, body, collectable) - } + ): DomainEvent = DomainEvent(id, name, occurredOn, body, collectable) } } 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 808c6bdf..f4cd139d 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,8 +16,7 @@ package dev.usbharu.hideout.core.domain.shared.domainevent +@Suppress("UnnecessaryAbstractClass") abstract class DomainEventBody(val map: Map) { - fun toMap(): Map { - return map - } + fun toMap(): Map = map } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/shared/domainevent/DomainEventStorable.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/shared/domainevent/DomainEventStorable.kt index 3fedb624..6e6b83b7 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/shared/domainevent/DomainEventStorable.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/shared/domainevent/DomainEventStorable.kt @@ -16,6 +16,7 @@ package dev.usbharu.hideout.core.domain.shared.domainevent +@Suppress("UnnecessaryAbstractClass") abstract class DomainEventStorable { private val domainEvents: MutableList = mutableListOf() diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/DelegateMediaProcessor.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/DelegateMediaProcessor.kt index 96607974..65cbc14d 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/DelegateMediaProcessor.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/DelegateMediaProcessor.kt @@ -11,12 +11,10 @@ class DelegateMediaProcessor( private val fileTypeDeterminer: FileTypeDeterminer, private val mediaProcessors: List ) : MediaProcessor { - override fun isSupported(mimeType: MimeType): Boolean { - return true - } + override fun isSupported(mimeType: MimeType): Boolean = true override suspend fun process(path: Path, filename: String, mimeType: MimeType?): ProcessedMedia { val fileType = fileTypeDeterminer.fileType(path, filename) return mediaProcessors.first { it.isSupported(fileType) }.process(path, filename, fileType) } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/FileTypeDeterminator.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/FileTypeDeterminer.kt similarity index 99% rename from hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/FileTypeDeterminator.kt rename to hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/FileTypeDeterminer.kt index 199ac249..83270bb6 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/FileTypeDeterminator.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/FileTypeDeterminer.kt @@ -5,4 +5,4 @@ import java.nio.file.Path interface FileTypeDeterminer { fun fileType(path: Path, filename: String): MimeType -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/MediaProcessor.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/MediaProcessor.kt index 35e0f060..687aa718 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/MediaProcessor.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/MediaProcessor.kt @@ -22,4 +22,4 @@ import java.nio.file.Path interface MediaProcessor { fun isSupported(mimeType: MimeType): Boolean suspend fun process(path: Path, filename: String, mimeType: MimeType?): ProcessedMedia -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/TikaFileTypeDeterminer.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/TikaFileTypeDeterminer.kt index 23ec5321..393798b7 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/TikaFileTypeDeterminer.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/media/TikaFileTypeDeterminer.kt @@ -48,4 +48,4 @@ class TikaFileTypeDeterminer : FileTypeDeterminer { companion object { private val logger = LoggerFactory.getLogger(TikaFileTypeDeterminer::class.java) } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/mediastore/MediaStore.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/mediastore/MediaStore.kt index dc34540e..d2ee30d1 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/mediastore/MediaStore.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/mediastore/MediaStore.kt @@ -5,4 +5,4 @@ import java.nio.file.Path interface MediaStore { suspend fun upload(path: Path, id: String): URI -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/awss3/AWSS3MediaStore.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/awss3/AWSS3MediaStore.kt index 0e87f031..47e30858 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/awss3/AWSS3MediaStore.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/awss3/AWSS3MediaStore.kt @@ -32,8 +32,7 @@ class AWSS3MediaStore( withContext(Dispatchers.IO) { s3Client.putObject(fileUploadRequest, RequestBody.fromFile(path)) } - val successSavedMedia = URI.create("${s3StorageConfig.publicUrl}/${s3StorageConfig.bucket}/${id}") - + val successSavedMedia = URI.create("${s3StorageConfig.publicUrl}/${s3StorageConfig.bucket}/$id") logger.info("SUCCESS Media upload. {}", id) logger.debug( @@ -48,4 +47,4 @@ class AWSS3MediaStore( companion object { private val logger = LoggerFactory.getLogger(AWSS3MediaStore::class.java) } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/FilterQueryMapper.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/FilterQueryMapper.kt index 9fe7081d..5b6039c4 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/FilterQueryMapper.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/FilterQueryMapper.kt @@ -34,17 +34,20 @@ class FilterQueryMapper(private val filterResultRowMapper: ResultRowMapper - FilterKeyword( - FilterKeywordId(resultRow.getOrNull(FilterKeywords.id) ?: return@mapNotNull null), - FilterKeywordKeyword( - resultRow.getOrNull(FilterKeywords.keyword) ?: return@mapNotNull null - ), - FilterMode.valueOf(resultRow.getOrNull(FilterKeywords.mode) ?: return@mapNotNull null) - ) - - }.toSet()) + reconstructWith( + it.mapNotNull { resultRow: ResultRow -> + FilterKeyword( + FilterKeywordId(resultRow.getOrNull(FilterKeywords.id) ?: return@mapNotNull null), + FilterKeywordKeyword( + resultRow.getOrNull(FilterKeywords.keyword) ?: return@mapNotNull null + ), + FilterMode.valueOf( + resultRow.getOrNull(FilterKeywords.mode) ?: return@mapNotNull null + ) + ) + }.toSet() + ) } } } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/FilterResultRowMapper.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/FilterResultRowMapper.kt index 13221bd7..e668f045 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/FilterResultRowMapper.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/FilterResultRowMapper.kt @@ -32,4 +32,4 @@ class FilterResultRowMapper : ResultRowMapper { FilterAction.valueOf(resultRow[Filters.filterAction]), emptySet() ) -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorInstanceRelationshipRepository.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorInstanceRelationshipRepository.kt index d32a3c59..ab7ab447 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorInstanceRelationshipRepository.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorInstanceRelationshipRepository.kt @@ -33,6 +33,9 @@ class ExposedActorInstanceRelationshipRepository(override val domainEventPublish ActorInstanceRelationshipRepository, AbstractRepository(), DomainEventPublishableRepository { + override val logger: Logger + get() = Companion.logger + override suspend fun save(actorInstanceRelationship: ActorInstanceRelationship): ActorInstanceRelationship { query { ActorInstanceRelationships.upsert { @@ -50,7 +53,8 @@ class ExposedActorInstanceRelationshipRepository(override val domainEventPublish override suspend fun delete(actorInstanceRelationship: ActorInstanceRelationship) { query { ActorInstanceRelationships.deleteWhere { - actorId eq actorInstanceRelationship.actorId.id and (instanceId eq actorInstanceRelationship.instanceId.instanceId) + actorId eq actorInstanceRelationship.actorId.id and + (instanceId eq actorInstanceRelationship.instanceId.instanceId) } } update(actorInstanceRelationship) @@ -63,15 +67,13 @@ class ExposedActorInstanceRelationshipRepository(override val domainEventPublish ActorInstanceRelationships .selectAll() .where { - ActorInstanceRelationships.actorId eq actorId.id and (ActorInstanceRelationships.instanceId eq instanceId.instanceId) + ActorInstanceRelationships.actorId eq actorId.id and + (ActorInstanceRelationships.instanceId eq instanceId.instanceId) } .singleOrNull() ?.toActorInstanceRelationship() } - override val logger: Logger - get() = Companion.logger - companion object { private val logger = LoggerFactory.getLogger(ExposedActorInstanceRelationshipRepository::class.java) } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorRepository.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorRepository.kt index fbdc1d62..8e184021 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorRepository.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorRepository.kt @@ -22,10 +22,6 @@ class ExposedActorRepository( override val logger: Logger get() = Companion.logger - companion object { - private val logger = LoggerFactory.getLogger(ExposedActorRepository::class.java) - } - override suspend fun save(actor: Actor): Actor { query { Actors.upsert { @@ -55,7 +51,6 @@ class ExposedActorRepository( it[emojis] = actor.emojis.joinToString(",") it[icon] = actor.icon?.id it[banner] = actor.banner?.id - } ActorsAlsoKnownAs.deleteWhere { actorId eq actor.id.id @@ -102,12 +97,16 @@ class ExposedActorRepository( .firstOrNull() } } + + companion object { + private val logger = LoggerFactory.getLogger(ExposedActorRepository::class.java) + } } object Actors : Table("actors") { val id = long("id") val name = varchar("name", ActorName.length) - val domain = varchar("domain", Domain.length) + val domain = varchar("domain", Domain.LENGTH) val screenName = varchar("screen_name", ActorScreenName.length) val description = varchar("description", ActorDescription.length) val inbox = varchar("inbox", 1000).uniqueIndex() diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedApplicationRepository.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedApplicationRepository.kt index f2d2552e..42d5c460 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedApplicationRepository.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedApplicationRepository.kt @@ -28,6 +28,9 @@ import org.springframework.stereotype.Repository @Repository class ExposedApplicationRepository : ApplicationRepository, AbstractRepository() { + override val logger: Logger + get() = Companion.logger + override suspend fun save(application: Application) = query { Applications.upsert { it[id] = application.applicationId.id @@ -40,9 +43,6 @@ class ExposedApplicationRepository : ApplicationRepository, AbstractRepository() Applications.deleteWhere { id eq application.applicationId.id } } - override val logger: Logger - get() = Companion.logger - companion object { private val logger = LoggerFactory.getLogger(ExposedApplicationRepository::class.java) } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedFilterRepository.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedFilterRepository.kt index 0bcbfc8e..9db15afb 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedFilterRepository.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedFilterRepository.kt @@ -30,6 +30,9 @@ import org.springframework.stereotype.Repository @Repository class ExposedFilterRepository(private val filterQueryMapper: QueryMapper) : FilterRepository, AbstractRepository() { + override val logger: Logger + get() = Companion.logger + override suspend fun save(filter: Filter): Filter = query { Filters.upsert { it[id] = filter.id.id @@ -69,9 +72,6 @@ class ExposedFilterRepository(private val filterQueryMapper: QueryMapper return filterQueryMapper.map(where).firstOrNull() } - override val logger: Logger - get() = Companion.logger - companion object { private val logger = LoggerFactory.getLogger(ExposedFilterRepository::class.java) } @@ -95,4 +95,4 @@ object FilterKeywords : Table("filter_keywords") { val mode = varchar("mode", 100) override val primaryKey: PrimaryKey = PrimaryKey(id) -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedPostRepository.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedPostRepository.kt index b02351d7..43d63e27 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedPostRepository.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedPostRepository.kt @@ -52,6 +52,8 @@ class ExposedPostRepository( PostRepository, AbstractRepository(), DomainEventPublishableRepository { + override val logger: Logger = Companion.logger + override suspend fun save(post: Post): Post { query { Posts.upsert { @@ -176,8 +178,6 @@ class ExposedPostRepository( update(post) } - override val logger: Logger = Companion.logger - companion object { private val logger = LoggerFactory.getLogger(ExposedPostRepository::class.java) } @@ -186,9 +186,9 @@ class ExposedPostRepository( object Posts : Table("posts") { val id = long("id") val actorId = long("actor_id").references(Actors.id) - val overview = varchar("overview", PostOverview.length).nullable() - val content = varchar("content", PostContent.contentLength) - val text = varchar("text", PostContent.textLength) + val overview = varchar("overview", PostOverview.LENGTH).nullable() + val content = varchar("content", PostContent.CONTENT_LENGTH) + val text = varchar("text", PostContent.TEXT_LENGTH) val createdAt = timestamp("created_at") val visibility = varchar("visibility", 100) val url = varchar("url", 1000) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedRelationshipRepository.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedRelationshipRepository.kt index e44b286f..c658754c 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedRelationshipRepository.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedRelationshipRepository.kt @@ -32,6 +32,9 @@ class ExposedRelationshipRepository(override val domainEventPublisher: DomainEve RelationshipRepository, AbstractRepository(), DomainEventPublishableRepository { + override val logger: Logger + get() = Companion.logger + override suspend fun save(relationship: Relationship): Relationship { query { Relationships.upsert { @@ -63,9 +66,6 @@ class ExposedRelationshipRepository(override val domainEventPublisher: DomainEve }.singleOrNull()?.toRelationships() } - override val logger: Logger - get() = Companion.logger - companion object { private val logger = LoggerFactory.getLogger(ExposedRelationshipRepository::class.java) } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/MediaRepositoryImpl.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/MediaRepositoryImpl.kt index 92306fbf..b9ab43de 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/MediaRepositoryImpl.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/MediaRepositoryImpl.kt @@ -27,6 +27,9 @@ import dev.usbharu.hideout.core.domain.model.media.Media as EntityMedia @Repository class MediaRepositoryImpl : MediaRepository, AbstractRepository() { + override val logger: Logger + get() = Companion.logger + override suspend fun findById(id: MediaId): dev.usbharu.hideout.core.domain.model.media.Media? { return query { return@query Media @@ -42,9 +45,6 @@ class MediaRepositoryImpl : MediaRepository, AbstractRepository() { } } - override val logger: Logger - get() = Companion.logger - override suspend fun save(media: EntityMedia): EntityMedia = query { if (Media.selectAll().where { Media.id eq media.id.id }.forUpdate().singleOrNull() != null ) { diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/localfilesystem/LocalFileSystemMediaStore.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/localfilesystem/LocalFileSystemMediaStore.kt index 2c794504..607ab397 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/localfilesystem/LocalFileSystemMediaStore.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/localfilesystem/LocalFileSystemMediaStore.kt @@ -26,7 +26,8 @@ class LocalFileSystemMediaStore( val fileSavePathString = fileSavePath.toAbsolutePath().toString() logger.info("MEDIA save. path: {}", fileSavePathString) - @Suppress("TooGenericExceptionCaught") try { + @Suppress("TooGenericExceptionCaught") + try { path.copyTo(fileSavePath) } catch (e: Exception) { logger.warn("FAILED to Save the media.", e) @@ -39,9 +40,7 @@ class LocalFileSystemMediaStore( private fun buildSavePath(savePath: Path, name: String): Path = savePath.resolve(name) - companion object { private val logger = LoggerFactory.getLogger(LocalFileSystemMediaStore::class.java) } - -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/common/GenerateBlurhash.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/common/GenerateBlurhash.kt index 5febf86b..6ee2893d 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/common/GenerateBlurhash.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/common/GenerateBlurhash.kt @@ -4,4 +4,4 @@ import java.awt.image.BufferedImage interface GenerateBlurhash { fun generateBlurhash(bufferedImage: BufferedImage): String -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/common/GenerateBlurhashImpl.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/common/GenerateBlurhashImpl.kt index 332fa4e9..cb269364 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/common/GenerateBlurhashImpl.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/common/GenerateBlurhashImpl.kt @@ -6,7 +6,5 @@ import java.awt.image.BufferedImage @Component class GenerateBlurhashImpl : GenerateBlurhash { - override fun generateBlurhash(bufferedImage: BufferedImage): String { - return BlurHash.encode(bufferedImage) - } -} \ No newline at end of file + override fun generateBlurhash(bufferedImage: BufferedImage): String = BlurHash.encode(bufferedImage) +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/image/ImageIOImageProcessor.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/image/ImageIOImageProcessor.kt index 91c337af..b297ff51 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/image/ImageIOImageProcessor.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/image/ImageIOImageProcessor.kt @@ -25,9 +25,8 @@ class ImageIOImageProcessor( private val imageIOImageConfig: ImageIOImageConfig, private val blurhash: GenerateBlurhash ) : MediaProcessor { - override fun isSupported(mimeType: MimeType): Boolean { - return mimeType.fileType == FileType.Image || mimeType.type == "image" - } + override fun isSupported(mimeType: MimeType): Boolean = + mimeType.fileType == FileType.Image || mimeType.type == "image" override suspend fun process(path: Path, filename: String, mimeType: MimeType?): ProcessedMedia { val read = ImageIO.read(path.inputStream()) @@ -76,4 +75,4 @@ class ImageIOImageProcessor( companion object { private val logger = LoggerFactory.getLogger(ImageIOImageProcessor::class.java) } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/video/FFmpegVideoProcessor.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/video/FFmpegVideoProcessor.kt index ae1959dd..22417894 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/video/FFmpegVideoProcessor.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/media/video/FFmpegVideoProcessor.kt @@ -25,9 +25,8 @@ class FFmpegVideoProcessor( private val fFmpegVideoConfig: FFmpegVideoConfig, private val generateBlurhash: GenerateBlurhash ) : MediaProcessor { - override fun isSupported(mimeType: MimeType): Boolean { - return mimeType.fileType == FileType.Video || mimeType.type == "video" - } + override fun isSupported(mimeType: MimeType): Boolean = + mimeType.fileType == FileType.Video || mimeType.type == "video" override suspend fun process(path: Path, filename: String, mimeType: MimeType?): ProcessedMedia { val tempFile = Files.createTempFile("hideout-movie-processor-", ".tmp") @@ -74,7 +73,6 @@ class FFmpegVideoProcessor( it.videoBitrate = videoBitRate it.start() - val frameConverter = Java2DFrameConverter() while (true) { @@ -114,4 +112,4 @@ class FFmpegVideoProcessor( companion object { private val logger = LoggerFactory.getLogger(FFmpegVideoProcessor::class.java) } -} \ No newline at end of file +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/HttpCommandExecutor.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/HttpCommandExecutor.kt index 2a04b380..e7b28ed5 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/HttpCommandExecutor.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/HttpCommandExecutor.kt @@ -23,7 +23,5 @@ open class HttpCommandExecutor( val ip: String, val userAgent: String, ) : CommandExecutor { - override fun toString(): String { - return "HttpCommandExecutor(executor='$executor', ip='$ip', userAgent='$userAgent')" - } + override fun toString(): String = "HttpCommandExecutor(executor='$executor', ip='$ip', userAgent='$userAgent')" } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/SpringSecurityPasswordEncoder.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/SpringSecurityPasswordEncoder.kt index 51ab4a81..799a8d44 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/SpringSecurityPasswordEncoder.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/SpringSecurityPasswordEncoder.kt @@ -24,7 +24,5 @@ class SpringSecurityPasswordEncoder( private val passwordEncoder: org.springframework.security.crypto.password.PasswordEncoder, ) : PasswordEncoder { - override suspend fun encode(input: String): String { - return passwordEncoder.encode(input) - } + override suspend fun encode(input: String): String = passwordEncoder.encode(input) } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/HideoutUserDetails.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/HideoutUserDetails.kt index 0b2f61d4..616868fe 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/HideoutUserDetails.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/HideoutUserDetails.kt @@ -40,17 +40,11 @@ class HideoutUserDetails( val userDetailsId: Long, ) : UserDetails { private val authorities: MutableSet = Collections.unmodifiableSet(authorities) - override fun getAuthorities(): MutableSet { - return authorities - } + override fun getAuthorities(): MutableSet = authorities - override fun getPassword(): String { - return password - } + override fun getPassword(): String = password - override fun getUsername(): String { - return username - } + override fun getUsername(): String = username override fun equals(other: Any?): Boolean { if (this === other) return true @@ -75,7 +69,12 @@ class HideoutUserDetails( } override fun toString(): String { - return "HideoutUserDetails(authorities=$authorities, password='$password', username='$username', userDetailsId=$userDetailsId)" + return "HideoutUserDetails(" + + "password='$password', " + + "username='$username', " + + "userDetailsId=$userDetailsId, " + + "authorities=$authorities" + + ")" } companion object { 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 39e8d6c8..98252d8e 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 @@ -32,6 +32,7 @@ class AuthController( private val springMvcCommandExecutorFactory: SpringMvcCommandExecutorFactory, ) { @GetMapping("/auth/sign_up") + @Suppress("FunctionOnlyReturningConstant") fun signUp(): String = "sign_up" @PostMapping("/auth/sign_up") diff --git a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/actor/ActorsTest.kt b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/actor/ActorsTest.kt index a0127a35..a8a67f4d 100644 --- a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/actor/ActorsTest.kt +++ b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/actor/ActorsTest.kt @@ -16,7 +16,7 @@ class ActorsTest { actor.suspend = true - assertContainsEvent(actor, ActorEvent.actorSuspend.eventName) + assertContainsEvent(actor, ActorEvent.ACTOR_SUSPEND.eventName) } @Test @@ -25,7 +25,7 @@ class ActorsTest { actor.suspend = false - assertContainsEvent(actor, ActorEvent.actorUnsuspend.eventName) + assertContainsEvent(actor, ActorEvent.ACTOR_UNSUSPEND.eventName) } @Test @@ -45,7 +45,7 @@ class ActorsTest { actor.moveTo = ActorId(100) - assertContainsEvent(actor, ActorEvent.move.eventName) + assertContainsEvent(actor, ActorEvent.MOVE.eventName) } @Test @@ -72,7 +72,7 @@ class ActorsTest { actor.description = ActorDescription("hoge fuga") - assertContainsEvent(actor, ActorEvent.update.eventName) + assertContainsEvent(actor, ActorEvent.UPDATE.eventName) } @Test @@ -81,7 +81,7 @@ class ActorsTest { actor.screenName = ActorScreenName("fuga hoge") - assertContainsEvent(actor, ActorEvent.update.eventName) + assertContainsEvent(actor, ActorEvent.UPDATE.eventName) } @Test @@ -106,7 +106,7 @@ class ActorsTest { assertEquals(ActorPostsCount.ZERO, actor.postsCount) assertNull(actor.followersCount) assertNull(actor.followingCount) - assertContainsEvent(actor, ActorEvent.delete.eventName) + assertContainsEvent(actor, ActorEvent.DELETE.eventName) } @Test @@ -116,7 +116,7 @@ class ActorsTest { actor.restore() assertFalse(actor.deleted) - assertContainsEvent(actor, ActorEvent.checkUpdate.eventName) + assertContainsEvent(actor, ActorEvent.CHECK_UPDATE.eventName) } @Test @@ -125,6 +125,6 @@ class ActorsTest { actor.checkUpdate() - assertContainsEvent(actor, ActorEvent.checkUpdate.eventName) + assertContainsEvent(actor, ActorEvent.CHECK_UPDATE.eventName) } } \ No newline at end of file diff --git a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/post/PostTest.kt b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/post/PostTest.kt index 65ab6cbb..c881d6e4 100644 --- a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/post/PostTest.kt +++ b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/post/PostTest.kt @@ -137,7 +137,7 @@ class PostTest { val actor = TestActorFactory.create(id = post.actorId.id, publicKey = ActorPublicKey("")) post.setVisibility(Visibility.PUBLIC, actor) - assertContainsEvent(post, PostEvent.update.eventName) + assertContainsEvent(post, PostEvent.UPDATE.eventName) } @Test @@ -189,7 +189,7 @@ class PostTest { val actor = TestActorFactory.create(id = post.actorId.id, publicKey = ActorPublicKey("")) post.setVisibleActors(setOf(ActorId(100)), actor) - assertContainsEvent(post, PostEvent.update.eventName) + assertContainsEvent(post, PostEvent.UPDATE.eventName) } @Test @@ -213,7 +213,7 @@ class PostTest { val post = TestPostFactory.create() val actor = TestActorFactory.create(id = post.actorId.id, publicKey = ActorPublicKey("")) post.setContent(PostContent("test", "test", emptyList()), actor) - assertContainsEvent(post, PostEvent.update.eventName) + assertContainsEvent(post, PostEvent.UPDATE.eventName) } @Test @@ -249,7 +249,7 @@ class PostTest { } assertEquals(overview, post.overview) - assertContainsEvent(post, PostEvent.update.eventName) + assertContainsEvent(post, PostEvent.UPDATE.eventName) } @Test 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 22411fb9..0480e70e 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 @@ -42,11 +42,11 @@ class GetFilterV1ApplicationService(private val filterRepository: FilterReposito phrase = filterKeyword?.keyword?.keyword, context = filter.filterContext.map { when (it) { - home -> V1Filter.Context.home - notifications -> V1Filter.Context.notifications - public -> V1Filter.Context.public - thread -> V1Filter.Context.thread - account -> V1Filter.Context.account + HOME -> V1Filter.Context.home + NOTIFICATION -> V1Filter.Context.notifications + PUBLIC -> V1Filter.Context.public + THREAD -> V1Filter.Context.thread + ACCOUNT -> V1Filter.Context.account } }, expiresAt = null, diff --git a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringFilterApi.kt b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringFilterApi.kt index 4bfdbea5..8d1c6f41 100644 --- a/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringFilterApi.kt +++ b/hideout-mastodon/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/SpringFilterApi.kt @@ -82,16 +82,16 @@ class SpringFilterApi( } val filterContext = v1FilterPostRequest.context.map { when (it) { - home -> FilterContext.home - notifications -> FilterContext.notifications - public -> FilterContext.public - thread -> FilterContext.thread - account -> FilterContext.account + home -> FilterContext.HOME + notifications -> FilterContext.NOTIFICATION + public -> FilterContext.PUBLIC + thread -> FilterContext.THREAD + account -> FilterContext.ACCOUNT } }.toSet() val filter = userRegisterFilterApplicationService.execute( RegisterFilter( - v1FilterPostRequest.phrase, filterContext, FilterAction.warn, + v1FilterPostRequest.phrase, filterContext, FilterAction.WARN, setOf(RegisterFilterKeyword(v1FilterPostRequest.phrase, filterMode)) ), executor ) @@ -140,17 +140,17 @@ class SpringFilterApi( title = filter.name, context = filter.filterContext.map { when (it) { - FilterContext.home -> Filter.Context.home - FilterContext.notifications -> Filter.Context.notifications - FilterContext.public -> Filter.Context.public - FilterContext.thread -> Filter.Context.thread - FilterContext.account -> Filter.Context.account + FilterContext.HOME -> Filter.Context.home + FilterContext.NOTIFICATION -> Filter.Context.notifications + FilterContext.PUBLIC -> Filter.Context.public + FilterContext.THREAD -> Filter.Context.thread + FilterContext.ACCOUNT -> Filter.Context.account } }, expiresAt = null, filterAction = when (filter.filterAction) { - FilterAction.warn -> Filter.FilterAction.warn - FilterAction.hide -> Filter.FilterAction.hide + FilterAction.WARN -> Filter.FilterAction.warn + FilterAction.HIDE -> Filter.FilterAction.hide }, keywords = filter.filterKeywords.map { @@ -197,17 +197,17 @@ class SpringFilterApi( filterName = filterPostRequest.title, filterContext = filterPostRequest.context.map { when (it) { - Context.home -> FilterContext.home - Context.notifications -> FilterContext.notifications - Context.public -> FilterContext.public - Context.thread -> FilterContext.thread - Context.account -> FilterContext.account + Context.home -> FilterContext.HOME + Context.notifications -> FilterContext.NOTIFICATION + Context.public -> FilterContext.PUBLIC + Context.thread -> FilterContext.THREAD + Context.account -> FilterContext.ACCOUNT } }.toSet(), filterAction = when (filterPostRequest.filterAction) { - FilterPostRequest.FilterAction.warn -> FilterAction.warn - FilterPostRequest.FilterAction.hide -> FilterAction.hide - null -> FilterAction.warn + FilterPostRequest.FilterAction.warn -> FilterAction.WARN + FilterPostRequest.FilterAction.hide -> FilterAction.HIDE + null -> FilterAction.WARN }, filterKeywords = filterPostRequest.keywordsAttributes.orEmpty().map { RegisterFilterKeyword(