style: fix lint

This commit is contained in:
usbharu 2024-06-16 16:54:56 +09:00
parent 0b062b6a68
commit 446b87e3d9
60 changed files with 309 additions and 318 deletions

View File

@ -47,23 +47,23 @@ data class UserDetail(
customEmojis: List<CustomEmoji>, customEmojis: List<CustomEmoji>,
): dev.usbharu.hideout.core.application.actor.UserDetail { ): dev.usbharu.hideout.core.application.actor.UserDetail {
return UserDetail( return UserDetail(
actor.id.id, id = actor.id.id,
userDetail.id.id, userDetailId = userDetail.id.id,
actor.name.name, name = actor.name.name,
actor.domain.domain, domain = actor.domain.domain,
actor.screenName.screenName, screenName = actor.screenName.screenName,
actor.url.toString(), url = actor.url.toString(),
actor.url.toString(), iconUrl = actor.url.toString(),
actor.description.description, description = actor.description.description,
actor.locked, locked = actor.locked,
customEmojis, emojis = customEmojis,
actor.createdAt, createdAt = actor.createdAt,
actor.lastPostAt, lastPostAt = actor.lastPostAt,
actor.postsCount.postsCount, postsCount = actor.postsCount.postsCount,
actor.followingCount?.relationshipCount, followingCount = actor.followingCount?.relationshipCount,
actor.followersCount?.relationshipCount, followersCount = actor.followersCount?.relationshipCount,
actor.moveTo?.id, moveTo = actor.moveTo?.id,
actor.suspend suspend = actor.suspend
) )
} }
} }

View File

@ -27,7 +27,8 @@ import org.springframework.stereotype.Service
@Service @Service
class UserDeleteFilterApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) : class UserDeleteFilterApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) :
AbstractApplicationService<DeleteFilter, Unit>( AbstractApplicationService<DeleteFilter, Unit>(
transaction, logger transaction,
logger
) { ) {
companion object { companion object {
private val logger = LoggerFactory.getLogger(UserDeleteFilterApplicationService::class.java) private val logger = LoggerFactory.getLogger(UserDeleteFilterApplicationService::class.java)

View File

@ -27,7 +27,8 @@ import org.springframework.stereotype.Service
@Service @Service
class UserGetFilterApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) : class UserGetFilterApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) :
AbstractApplicationService<GetFilter, Filter>( AbstractApplicationService<GetFilter, Filter>(
transaction, logger transaction,
logger
) { ) {
override suspend fun internalExecute(command: GetFilter, executor: CommandExecutor): Filter { override suspend fun internalExecute(command: GetFilter, executor: CommandExecutor): Filter {
val filter = filterRepository.findByFilterId(FilterId(command.filterId)) ?: throw Exception("Not Found") val filter = filterRepository.findByFilterId(FilterId(command.filterId)) ?: throw Exception("Not Found")

View File

@ -34,7 +34,8 @@ class UserRegisterFilterApplicationService(
transaction: Transaction, transaction: Transaction,
) : ) :
AbstractApplicationService<RegisterFilter, Filter>( AbstractApplicationService<RegisterFilter, Filter>(
transaction, logger transaction,
logger
) { ) {
companion object { companion object {
@ -44,14 +45,13 @@ class UserRegisterFilterApplicationService(
override suspend fun internalExecute(command: RegisterFilter, executor: CommandExecutor): Filter { override suspend fun internalExecute(command: RegisterFilter, executor: CommandExecutor): Filter {
require(executor is UserDetailGettableCommandExecutor) require(executor is UserDetailGettableCommandExecutor)
val filter = dev.usbharu.hideout.core.domain.model.filter.Filter.create( val filter = dev.usbharu.hideout.core.domain.model.filter.Filter.create(
FilterId(idGenerateService.generateId()), id = FilterId(idGenerateService.generateId()),
UserDetailId(executor.userDetailId), userDetailId = UserDetailId(executor.userDetailId),
FilterName(command.filterName), name = FilterName(command.filterName),
command.filterContext, filterContext = command.filterContext,
command.filterAction, filterAction = command.filterAction,
command.filterKeywords filterKeywords = command.filterKeywords
.map { .map {
FilterKeyword( FilterKeyword(
FilterKeywordId(idGenerateService.generateId()), FilterKeywordId(idGenerateService.generateId()),

View File

@ -40,18 +40,18 @@ class InitLocalInstanceApplicationService(
if (findByUrl == null) { if (findByUrl == null) {
val instance = Instance( val instance = Instance(
InstanceId(idGenerateService.generateId()), id = InstanceId(idGenerateService.generateId()),
InstanceName(applicationConfig.url.host), name = InstanceName(applicationConfig.url.host),
InstanceDescription(""), description = InstanceDescription(""),
applicationConfig.url.toURI(), url = applicationConfig.url.toURI(),
applicationConfig.url.toURI(), iconUrl = applicationConfig.url.toURI(),
null, sharedInbox = null,
InstanceSoftware("hideout"), software = InstanceSoftware("hideout"),
InstanceVersion(buildProperties.version), version = InstanceVersion(buildProperties.version),
false, isBlocked = false,
false, isMuted = false,
InstanceModerationNote(""), moderationNote = InstanceModerationNote(""),
Instant.now(), createdAt = Instant.now(),
) )
instanceRepository.save(instance) instanceRepository.save(instance)
} }

View File

@ -36,7 +36,8 @@ class UploadMediaApplicationService(
private val idGenerateService: IdGenerateService, private val idGenerateService: IdGenerateService,
transaction: Transaction transaction: Transaction
) : AbstractApplicationService<UploadMedia, Media>( ) : AbstractApplicationService<UploadMedia, Media>(
transaction, logger transaction,
logger
) { ) {
companion object { companion object {
private val logger = LoggerFactory.getLogger(UploadMediaApplicationService::class.java) 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 uri = mediaStore.upload(process.path, "$id.${process.mimeType.subtype}")
val media = MediaModel( val media = MediaModel(
MediaId(id), id = MediaId(id),
MediaName(command.name), name = MediaName(command.name),
uri, url = uri,
command.remoteUri, remoteUrl = command.remoteUri,
thumbnailUri, thumbnailUrl = thumbnailUri,
process.fileType, type = process.fileType,
process.mimeType, mimeType = process.mimeType,
process.blurHash?.let { MediaBlurHash(it) }, blurHash = process.blurHash?.let { MediaBlurHash(it) },
command.description?.let { MediaDescription(it) } description = command.description?.let { MediaDescription(it) }
) )
mediaRepository.save(media) mediaRepository.save(media)
return Media.of(media) return Media.of(media)
} }
} }

View File

@ -39,19 +39,19 @@ data class Post(
companion object { companion object {
fun of(post: Post): dev.usbharu.hideout.core.application.post.Post { fun of(post: Post): dev.usbharu.hideout.core.application.post.Post {
return Post( return Post(
post.id.id, id = post.id.id,
post.actorId.id, actorId = post.actorId.id,
post.overview?.overview, overview = post.overview?.overview,
post.text, text = post.text,
post.content.content, content = post.content.content,
post.createdAt, createdAt = post.createdAt,
post.visibility, visibility = post.visibility,
post.url, url = post.url,
post.repostId?.id, repostId = post.repostId?.id,
post.replyId?.id, replyId = post.replyId?.id,
post.sensitive, sensitive = post.sensitive,
post.mediaIds.map { it.id }, mediaIds = post.mediaIds.map { it.id },
post.moveTo?.id moveTo = post.moveTo?.id
) )
} }
} }

View File

@ -40,18 +40,18 @@ data class Relationship(
actorInstanceRelationship: ActorInstanceRelationship, actorInstanceRelationship: ActorInstanceRelationship,
): dev.usbharu.hideout.core.application.relationship.get.Relationship { ): dev.usbharu.hideout.core.application.relationship.get.Relationship {
return Relationship( return Relationship(
relationship.actorId.id, actorId = relationship.actorId.id,
relationship.targetActorId.id, targetId = relationship.targetActorId.id,
relationship.following, following = relationship.following,
relationship2.following, followedBy = relationship2.following,
relationship.blocking, blocking = relationship.blocking,
relationship2.blocking, blockedBy = relationship2.blocking,
relationship.muting, muting = relationship.muting,
relationship.followRequesting, followRequesting = relationship.followRequesting,
relationship2.followRequesting, followRequestedBy = relationship2.followRequesting,
actorInstanceRelationship.isBlocking(), domainBlocking = actorInstanceRelationship.isBlocking(),
actorInstanceRelationship.isMuting(), domainMuting = actorInstanceRelationship.isMuting(),
actorInstanceRelationship.isDoNotSendPrivate() domainDoNotSendPrivate = actorInstanceRelationship.isDoNotSendPrivate()
) )
} }
} }

View File

@ -37,10 +37,10 @@ class ActorEventBody(actor: Actor) : DomainEventBody(
) )
enum class ActorEvent(val eventName: String, val collectable: Boolean = true) { enum class ActorEvent(val eventName: String, val collectable: Boolean = true) {
update("ActorUpdate"), UPDATE("ActorUpdate"),
delete("ActorDelete"), DELETE("ActorDelete"),
checkUpdate("ActorCheckUpdate"), CHECK_UPDATE("ActorCheckUpdate"),
move("ActorMove"), MOVE("ActorMove"),
actorSuspend("ActorSuspend"), ACTOR_SUSPEND("ActorSuspend"),
actorUnsuspend("ActorUnsuspend"), ACTOR_UNSUSPEND("ActorUnsuspend"),
} }

View File

@ -41,7 +41,7 @@ class ActorInstanceRelationshipEventBody(actorInstanceRelationship: ActorInstanc
) )
enum class ActorInstanceRelationshipEvent(val eventName: String) { enum class ActorInstanceRelationshipEvent(val eventName: String) {
block("ActorInstanceBlock"), BLOCK("ActorInstanceBlock"),
mute("ActorInstanceMute"), MUTE("ActorInstanceMute"),
unmute("ActorInstanceUnmute"), UNMUTE("ActorInstanceUnmute"),
} }

View File

@ -32,5 +32,5 @@ class InstanceEventFactory(private val instance: Instance) {
class InstanceEventBody(instance: Instance) : DomainEventBody(mapOf("instance" to instance)) class InstanceEventBody(instance: Instance) : DomainEventBody(mapOf("instance" to instance))
enum class InstanceEvent(val eventName: String) { enum class InstanceEvent(val eventName: String) {
update("InstanceUpdate") UPDATE("InstanceUpdate")
} }

View File

@ -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)) class PostEventBody(post: Post, actor: Actor?) : DomainEventBody(mapOf("post" to post, "actor" to actor))
enum class PostEvent(val eventName: String) { enum class PostEvent(val eventName: String) {
delete("PostDelete"), DELETE("PostDelete"),
update("PostUpdate"), UPDATE("PostUpdate"),
create("PostCreate"), CREATE("PostCreate"),
checkUpdate("PostCheckUpdate"), CHECK_UPDATE("PostCheckUpdate"),
} }

View File

@ -29,12 +29,12 @@ class RelationshipEventFactory(private val relationship: Relationship) {
class RelationshipEventBody(relationship: Relationship) : DomainEventBody(mapOf("relationship" to relationship)) class RelationshipEventBody(relationship: Relationship) : DomainEventBody(mapOf("relationship" to relationship))
enum class RelationshipEvent(val eventName: String) { enum class RelationshipEvent(val eventName: String) {
follow("RelationshipFollow"), FOLLOW("RelationshipFollow"),
unfollow("RelationshipUnfollow"), UNFOLLOW("RelationshipUnfollow"),
block("RelationshipBlock"), BLOCK("RelationshipBlock"),
unblock("RelationshipUnblock"), UNBLOCK("RelationshipUnblock"),
mute("RelationshipMute"), MUTE("RelationshipMute"),
unmute("RelationshipUnmute"), UNMUTE("RelationshipUnmute"),
followRequest("RelationshipFollowRequest"), FOLLOW_REQUEST("RelationshipFollowRequest"),
unfollowRequest("RelationshipUnfollowRequest"), UNFOLLOW_REQUEST("RelationshipUnfollowRequest"),
} }

View File

@ -26,6 +26,7 @@ import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable
import java.net.URI import java.net.URI
import java.time.Instant import java.time.Instant
@Suppress("LongParameterList")
class Actor( class Actor(
val id: ActorId, val id: ActorId,
val name: ActorName, val name: ActorName,
@ -62,7 +63,7 @@ class Actor(
private set private set
fun setBannerUrl(banner: MediaId?, actor: Actor) { fun setBannerUrl(banner: MediaId?, actor: Actor) {
addDomainEvent(ActorDomainEventFactory(this).createEvent(update)) addDomainEvent(ActorDomainEventFactory(this).createEvent(UPDATE))
this.banner = banner this.banner = banner
} }
@ -70,7 +71,7 @@ class Actor(
private set private set
fun setIconUrl(icon: MediaId?, actor: Actor) { fun setIconUrl(icon: MediaId?, actor: Actor) {
addDomainEvent(ActorDomainEventFactory(this).createEvent(update)) addDomainEvent(ActorDomainEventFactory(this).createEvent(UPDATE))
this.icon = icon this.icon = icon
} }
@ -86,9 +87,9 @@ class Actor(
var suspend = suspend var suspend = suspend
set(value) { set(value) {
if (field != value && value) { if (field != value && value) {
addDomainEvent(ActorDomainEventFactory(this).createEvent(actorSuspend)) addDomainEvent(ActorDomainEventFactory(this).createEvent(ACTOR_SUSPEND))
} else if (field != value && !value) { } else if (field != value && !value) {
addDomainEvent(ActorDomainEventFactory(this).createEvent(actorUnsuspend)) addDomainEvent(ActorDomainEventFactory(this).createEvent(ACTOR_UNSUSPEND))
} }
field = value field = value
} }
@ -102,7 +103,7 @@ class Actor(
var moveTo = moveTo var moveTo = moveTo
set(value) { set(value) {
require(value != id) require(value != id)
addDomainEvent(ActorDomainEventFactory(this).createEvent(move)) addDomainEvent(ActorDomainEventFactory(this).createEvent(MOVE))
field = value field = value
} }
@ -111,12 +112,12 @@ class Actor(
var description = description var description = description
set(value) { set(value) {
addDomainEvent(ActorDomainEventFactory(this).createEvent(update)) addDomainEvent(ActorDomainEventFactory(this).createEvent(UPDATE))
field = value field = value
} }
var screenName = screenName var screenName = screenName
set(value) { set(value) {
addDomainEvent(ActorDomainEventFactory(this).createEvent(update)) addDomainEvent(ActorDomainEventFactory(this).createEvent(UPDATE))
field = value field = value
} }
@ -125,7 +126,7 @@ class Actor(
fun delete() { fun delete() {
if (deleted.not()) { if (deleted.not()) {
addDomainEvent(ActorDomainEventFactory(this).createEvent(delete)) addDomainEvent(ActorDomainEventFactory(this).createEvent(DELETE))
screenName = ActorScreenName.empty screenName = ActorScreenName.empty
description = ActorDescription.empty description = ActorDescription.empty
emojis = emptySet() emojis = emptySet()
@ -142,6 +143,6 @@ class Actor(
} }
fun checkUpdate() { fun checkUpdate() {
addDomainEvent(ActorDomainEventFactory(this).createEvent(checkUpdate)) addDomainEvent(ActorDomainEventFactory(this).createEvent(CHECK_UPDATE))
} }
} }

View File

@ -30,7 +30,7 @@ data class ActorInstanceRelationship(
private var doNotSendPrivate: Boolean = false, private var doNotSendPrivate: Boolean = false,
) : DomainEventStorable() { ) : DomainEventStorable() {
fun block(): ActorInstanceRelationship { fun block(): ActorInstanceRelationship {
addDomainEvent(ActorInstanceRelationshipDomainEventFactory(this).createEvent(block)) addDomainEvent(ActorInstanceRelationshipDomainEventFactory(this).createEvent(BLOCK))
blocking = true blocking = true
return this return this
} }
@ -41,13 +41,13 @@ data class ActorInstanceRelationship(
} }
fun mute(): ActorInstanceRelationship { fun mute(): ActorInstanceRelationship {
addDomainEvent(ActorInstanceRelationshipDomainEventFactory(this).createEvent(mute)) addDomainEvent(ActorInstanceRelationshipDomainEventFactory(this).createEvent(MUTE))
muting = true muting = true
return this return this
} }
fun unmute(): ActorInstanceRelationship { fun unmute(): ActorInstanceRelationship {
addDomainEvent(ActorInstanceRelationshipDomainEventFactory(this).createEvent(unmute)) addDomainEvent(ActorInstanceRelationshipDomainEventFactory(this).createEvent(UNMUTE))
muting = false muting = false
return this return this
} }

View File

@ -41,12 +41,12 @@ class Filter(
fun reconstructWith(filterKeywords: Set<FilterKeyword>): Filter { fun reconstructWith(filterKeywords: Set<FilterKeyword>): Filter {
return Filter( return Filter(
this.id, id = this.id,
this.userDetailId, userDetailId = this.userDetailId,
this.name, name = this.name,
this.filterContext, filterContext = this.filterContext,
this.filterAction, filterAction = this.filterAction,
filterKeywords filterKeywords = filterKeywords
) )
} }
@ -61,6 +61,7 @@ class Filter(
SET_KEYWORDS SET_KEYWORDS
} }
@Suppress("LongParameterList")
fun create( fun create(
id: FilterId, id: FilterId,
userDetailId: UserDetailId, userDetailId: UserDetailId,

View File

@ -1,6 +1,6 @@
package dev.usbharu.hideout.core.domain.model.filter package dev.usbharu.hideout.core.domain.model.filter
enum class FilterAction { enum class FilterAction {
warn, WARN,
hide HIDE
} }

View File

@ -1,9 +1,9 @@
package dev.usbharu.hideout.core.domain.model.filter package dev.usbharu.hideout.core.domain.model.filter
enum class FilterContext { enum class FilterContext {
home, HOME,
notifications, NOTIFICATION,
public, PUBLIC,
thread, THREAD,
account ACCOUNT
} }

View File

@ -22,6 +22,7 @@ import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable
import java.net.URI import java.net.URI
import java.time.Instant import java.time.Instant
@Suppress("LongParameterList")
class Instance( class Instance(
val id: InstanceId, val id: InstanceId,
var name: InstanceName, var name: InstanceName,
@ -39,7 +40,7 @@ class Instance(
var iconUrl = iconUrl var iconUrl = iconUrl
set(value) { set(value) {
addDomainEvent(InstanceEventFactory(this).createEvent(InstanceEvent.update)) addDomainEvent(InstanceEventFactory(this).createEvent(InstanceEvent.UPDATE))
field = value field = value
} }

View File

@ -28,6 +28,7 @@ import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable
import java.net.URI import java.net.URI
import java.time.Instant import java.time.Instant
@Suppress("LongParameterList", "TooManyFunctions")
class Post( class Post(
val id: PostId, val id: PostId,
actorId: ActorId, actorId: ActorId,
@ -67,7 +68,7 @@ class Post(
require(deleted.not()) require(deleted.not())
if (this.visibility != visibility) { if (this.visibility != visibility) {
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.update)) addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
} }
this.visibility = visibility this.visibility = visibility
} }
@ -79,7 +80,7 @@ class Post(
require(isAllow(actor, UPDATE, this)) require(isAllow(actor, UPDATE, this))
require(deleted.not()) require(deleted.not())
if (visibility == Visibility.DIRECT) { if (visibility == Visibility.DIRECT) {
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.update)) addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
this.visibleActors = this.visibleActors.plus(visibleActors) this.visibleActors = this.visibleActors.plus(visibleActors)
} }
} }
@ -97,7 +98,7 @@ class Post(
require(isAllow(actor, UPDATE, this)) require(isAllow(actor, UPDATE, this))
require(deleted.not()) require(deleted.not())
if (this.content != content) { if (this.content != content) {
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.update)) addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
} }
this.content = content this.content = content
} }
@ -115,7 +116,7 @@ class Post(
require(isAllow(actor, UPDATE, this)) require(isAllow(actor, UPDATE, this))
require(deleted.not()) require(deleted.not())
if (this.overview != overview) { if (this.overview != overview) {
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.update)) addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
} }
this.overview = overview this.overview = overview
} }
@ -127,7 +128,7 @@ class Post(
isAllow(actor, UPDATE, this) isAllow(actor, UPDATE, this)
require(deleted.not()) require(deleted.not())
if (this.sensitive != sensitive) { if (this.sensitive != sensitive) {
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.update)) addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
} }
this.sensitive = sensitive this.sensitive = sensitive
} }
@ -160,7 +161,7 @@ class Post(
fun addMediaIds(mediaIds: List<MediaId>, actor: Actor) { fun addMediaIds(mediaIds: List<MediaId>, actor: Actor) {
require(isAllow(actor, UPDATE, this)) require(isAllow(actor, UPDATE, this))
require(deleted.not()) require(deleted.not())
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.update)) addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.UPDATE))
this.mediaIds = this.mediaIds.plus(mediaIds).distinct() this.mediaIds = this.mediaIds.plus(mediaIds).distinct()
} }
@ -170,7 +171,7 @@ class Post(
fun delete(actor: Actor) { fun delete(actor: Actor) {
isAllow(actor, DELETE, this) isAllow(actor, DELETE, this)
if (deleted.not()) { if (deleted.not()) {
addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.delete)) addDomainEvent(PostDomainEventFactory(this, actor).createEvent(PostEvent.DELETE))
content = PostContent.empty content = PostContent.empty
overview = null overview = null
mediaIds = emptyList() mediaIds = emptyList()
@ -179,7 +180,7 @@ class Post(
} }
fun checkUpdate() { fun checkUpdate() {
addDomainEvent(PostDomainEventFactory(this).createEvent(PostEvent.checkUpdate)) addDomainEvent(PostDomainEventFactory(this).createEvent(PostEvent.CHECK_UPDATE))
} }
fun restore(content: PostContent, overview: PostOverview?, mediaIds: List<MediaId>) { fun restore(content: PostContent, overview: PostOverview?, mediaIds: List<MediaId>) {
@ -219,9 +220,7 @@ class Post(
return id == other.id return id == other.id
} }
override fun hashCode(): Int { override fun hashCode(): Int = id.hashCode()
return id.hashCode()
}
fun reconstructWith(mediaIds: List<MediaId>, emojis: List<EmojiId>, visibleActors: Set<ActorId>): Post { fun reconstructWith(mediaIds: List<MediaId>, emojis: List<EmojiId>, visibleActors: Set<ActorId>): Post {
return Post( return Post(
@ -245,6 +244,7 @@ class Post(
} }
companion object { companion object {
@Suppress("LongParameterList")
fun create( fun create(
id: PostId, id: PostId,
actorId: ActorId, actorId: ActorId,
@ -274,24 +274,24 @@ class Post(
} }
val post = Post( val post = Post(
id, id = id,
actorId, actorId = actorId,
overview, overview = overview,
content, content = content,
createdAt, createdAt = createdAt,
visibility1, visibility = visibility1,
url, url = url,
repostId, repostId = repostId,
replyId, replyId = replyId,
sensitive, sensitive = sensitive,
apId, apId = apId,
deleted, deleted = deleted,
mediaIds, mediaIds = mediaIds,
visibleActors, visibleActors = visibleActors,
hide, hide = hide,
moveTo moveTo = moveTo
) )
post.addDomainEvent(PostDomainEventFactory(post).createEvent(PostEvent.create)) post.addDomainEvent(PostDomainEventFactory(post).createEvent(PostEvent.CREATE))
return post return post
} }

View File

@ -22,7 +22,7 @@ data class PostContent(val text: String, val content: String, val emojiIds: List
companion object { companion object {
val empty = PostContent("", "", emptyList()) val empty = PostContent("", "", emptyList())
val contentLength = 5000 const val CONTENT_LENGTH = 5000
val textLength = 3000 const val TEXT_LENGTH = 3000
} }
} }

View File

@ -19,6 +19,6 @@ package dev.usbharu.hideout.core.domain.model.post
@JvmInline @JvmInline
value class PostOverview(val overview: String) { value class PostOverview(val overview: String) {
companion object { companion object {
val length = 100 const val LENGTH = 100
} }
} }

View File

@ -46,33 +46,33 @@ class Relationship(
fun follow() { fun follow() {
require(blocking.not()) require(blocking.not())
following = true following = true
addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.follow)) addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.FOLLOW))
} }
fun unfollow() { fun unfollow() {
following = false following = false
addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.unfollow)) addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.UNFOLLOW))
} }
fun block() { fun block() {
require(following.not()) require(following.not())
blocking = true blocking = true
addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.block)) addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.BLOCK))
} }
fun unblock() { fun unblock() {
blocking = false blocking = false
addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.unblock)) addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.UNBLOCK))
} }
fun mute() { fun mute() {
muting = true muting = true
addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.mute)) addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.MUTE))
} }
fun unmute() { fun unmute() {
muting = false muting = false
addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.unmute)) addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.UNMUTE))
} }
fun muteFollowRequest() { fun muteFollowRequest() {
@ -86,12 +86,12 @@ class Relationship(
fun followRequest() { fun followRequest() {
require(blocking.not()) require(blocking.not())
followRequesting = true followRequesting = true
addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.followRequest)) addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.FOLLOW_REQUEST))
} }
fun unfollowRequest() { fun unfollowRequest() {
followRequesting = false followRequesting = false
addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.unfollowRequest)) addDomainEvent(RelationshipEventFactory(this).createEvent(RelationshipEvent.UNFOLLOW_REQUEST))
} }
fun acceptFollowRequest() { fun acceptFollowRequest() {

View File

@ -19,10 +19,10 @@ package dev.usbharu.hideout.core.domain.model.shared
@JvmInline @JvmInline
value class Domain(val domain: String) { value class Domain(val domain: String) {
init { init {
require(domain.length <= length) require(domain.length <= LENGTH)
} }
companion object { companion object {
val length = 1000 const val LENGTH = 1000
} }
} }

View File

@ -27,6 +27,17 @@ class UserDetail private constructor(
var lastMigration: Instant? = null, 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 { companion object {
fun create( fun create(
id: UserDetailId, 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()
}
} }

View File

@ -36,9 +36,8 @@ data class DomainEvent(
val collectable: Boolean = false val collectable: Boolean = false
) { ) {
companion object { companion object {
fun create(name: String, body: DomainEventBody, collectable: Boolean = false): DomainEvent { fun create(name: String, body: DomainEventBody, collectable: Boolean = false): DomainEvent =
return DomainEvent(UUID.randomUUID().toString(), name, Instant.now(), body, collectable) DomainEvent(UUID.randomUUID().toString(), name, Instant.now(), body, collectable)
}
fun reconstruct( fun reconstruct(
id: String, id: String,
@ -46,8 +45,6 @@ data class DomainEvent(
occurredOn: Instant, occurredOn: Instant,
body: DomainEventBody, body: DomainEventBody,
collectable: Boolean collectable: Boolean
): DomainEvent { ): DomainEvent = DomainEvent(id, name, occurredOn, body, collectable)
return DomainEvent(id, name, occurredOn, body, collectable)
}
} }
} }

View File

@ -16,8 +16,7 @@
package dev.usbharu.hideout.core.domain.shared.domainevent package dev.usbharu.hideout.core.domain.shared.domainevent
@Suppress("UnnecessaryAbstractClass")
abstract class DomainEventBody(val map: Map<String, Any?>) { abstract class DomainEventBody(val map: Map<String, Any?>) {
fun toMap(): Map<String, Any?> { fun toMap(): Map<String, Any?> = map
return map
}
} }

View File

@ -16,6 +16,7 @@
package dev.usbharu.hideout.core.domain.shared.domainevent package dev.usbharu.hideout.core.domain.shared.domainevent
@Suppress("UnnecessaryAbstractClass")
abstract class DomainEventStorable { abstract class DomainEventStorable {
private val domainEvents: MutableList<DomainEvent> = mutableListOf() private val domainEvents: MutableList<DomainEvent> = mutableListOf()

View File

@ -11,9 +11,7 @@ class DelegateMediaProcessor(
private val fileTypeDeterminer: FileTypeDeterminer, private val fileTypeDeterminer: FileTypeDeterminer,
private val mediaProcessors: List<MediaProcessor> private val mediaProcessors: List<MediaProcessor>
) : MediaProcessor { ) : MediaProcessor {
override fun isSupported(mimeType: MimeType): Boolean { override fun isSupported(mimeType: MimeType): Boolean = true
return true
}
override suspend fun process(path: Path, filename: String, mimeType: MimeType?): ProcessedMedia { override suspend fun process(path: Path, filename: String, mimeType: MimeType?): ProcessedMedia {
val fileType = fileTypeDeterminer.fileType(path, filename) val fileType = fileTypeDeterminer.fileType(path, filename)

View File

@ -32,8 +32,7 @@ class AWSS3MediaStore(
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
s3Client.putObject(fileUploadRequest, RequestBody.fromFile(path)) 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.info("SUCCESS Media upload. {}", id)
logger.debug( logger.debug(

View File

@ -34,16 +34,19 @@ class FilterQueryMapper(private val filterResultRowMapper: ResultRowMapper<Filte
.first() .first()
.let(filterResultRowMapper::map) .let(filterResultRowMapper::map)
.apply { .apply {
reconstructWith(it.mapNotNull { resultRow: ResultRow -> reconstructWith(
it.mapNotNull { resultRow: ResultRow ->
FilterKeyword( FilterKeyword(
FilterKeywordId(resultRow.getOrNull(FilterKeywords.id) ?: return@mapNotNull null), FilterKeywordId(resultRow.getOrNull(FilterKeywords.id) ?: return@mapNotNull null),
FilterKeywordKeyword( FilterKeywordKeyword(
resultRow.getOrNull(FilterKeywords.keyword) ?: return@mapNotNull null resultRow.getOrNull(FilterKeywords.keyword) ?: return@mapNotNull null
), ),
FilterMode.valueOf(resultRow.getOrNull(FilterKeywords.mode) ?: return@mapNotNull null) FilterMode.valueOf(
resultRow.getOrNull(FilterKeywords.mode) ?: return@mapNotNull null
)
)
}.toSet()
) )
}.toSet())
} }
} }
} }

View File

@ -33,6 +33,9 @@ class ExposedActorInstanceRelationshipRepository(override val domainEventPublish
ActorInstanceRelationshipRepository, ActorInstanceRelationshipRepository,
AbstractRepository(), AbstractRepository(),
DomainEventPublishableRepository<ActorInstanceRelationship> { DomainEventPublishableRepository<ActorInstanceRelationship> {
override val logger: Logger
get() = Companion.logger
override suspend fun save(actorInstanceRelationship: ActorInstanceRelationship): ActorInstanceRelationship { override suspend fun save(actorInstanceRelationship: ActorInstanceRelationship): ActorInstanceRelationship {
query { query {
ActorInstanceRelationships.upsert { ActorInstanceRelationships.upsert {
@ -50,7 +53,8 @@ class ExposedActorInstanceRelationshipRepository(override val domainEventPublish
override suspend fun delete(actorInstanceRelationship: ActorInstanceRelationship) { override suspend fun delete(actorInstanceRelationship: ActorInstanceRelationship) {
query { query {
ActorInstanceRelationships.deleteWhere { 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) update(actorInstanceRelationship)
@ -63,15 +67,13 @@ class ExposedActorInstanceRelationshipRepository(override val domainEventPublish
ActorInstanceRelationships ActorInstanceRelationships
.selectAll() .selectAll()
.where { .where {
ActorInstanceRelationships.actorId eq actorId.id and (ActorInstanceRelationships.instanceId eq instanceId.instanceId) ActorInstanceRelationships.actorId eq actorId.id and
(ActorInstanceRelationships.instanceId eq instanceId.instanceId)
} }
.singleOrNull() .singleOrNull()
?.toActorInstanceRelationship() ?.toActorInstanceRelationship()
} }
override val logger: Logger
get() = Companion.logger
companion object { companion object {
private val logger = LoggerFactory.getLogger(ExposedActorInstanceRelationshipRepository::class.java) private val logger = LoggerFactory.getLogger(ExposedActorInstanceRelationshipRepository::class.java)
} }

View File

@ -22,10 +22,6 @@ class ExposedActorRepository(
override val logger: Logger override val logger: Logger
get() = Companion.logger get() = Companion.logger
companion object {
private val logger = LoggerFactory.getLogger(ExposedActorRepository::class.java)
}
override suspend fun save(actor: Actor): Actor { override suspend fun save(actor: Actor): Actor {
query { query {
Actors.upsert { Actors.upsert {
@ -55,7 +51,6 @@ class ExposedActorRepository(
it[emojis] = actor.emojis.joinToString(",") it[emojis] = actor.emojis.joinToString(",")
it[icon] = actor.icon?.id it[icon] = actor.icon?.id
it[banner] = actor.banner?.id it[banner] = actor.banner?.id
} }
ActorsAlsoKnownAs.deleteWhere { ActorsAlsoKnownAs.deleteWhere {
actorId eq actor.id.id actorId eq actor.id.id
@ -102,12 +97,16 @@ class ExposedActorRepository(
.firstOrNull() .firstOrNull()
} }
} }
companion object {
private val logger = LoggerFactory.getLogger(ExposedActorRepository::class.java)
}
} }
object Actors : Table("actors") { object Actors : Table("actors") {
val id = long("id") val id = long("id")
val name = varchar("name", ActorName.length) 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 screenName = varchar("screen_name", ActorScreenName.length)
val description = varchar("description", ActorDescription.length) val description = varchar("description", ActorDescription.length)
val inbox = varchar("inbox", 1000).uniqueIndex() val inbox = varchar("inbox", 1000).uniqueIndex()

View File

@ -28,6 +28,9 @@ import org.springframework.stereotype.Repository
@Repository @Repository
class ExposedApplicationRepository : ApplicationRepository, AbstractRepository() { class ExposedApplicationRepository : ApplicationRepository, AbstractRepository() {
override val logger: Logger
get() = Companion.logger
override suspend fun save(application: Application) = query { override suspend fun save(application: Application) = query {
Applications.upsert { Applications.upsert {
it[id] = application.applicationId.id it[id] = application.applicationId.id
@ -40,9 +43,6 @@ class ExposedApplicationRepository : ApplicationRepository, AbstractRepository()
Applications.deleteWhere { id eq application.applicationId.id } Applications.deleteWhere { id eq application.applicationId.id }
} }
override val logger: Logger
get() = Companion.logger
companion object { companion object {
private val logger = LoggerFactory.getLogger(ExposedApplicationRepository::class.java) private val logger = LoggerFactory.getLogger(ExposedApplicationRepository::class.java)
} }

View File

@ -30,6 +30,9 @@ import org.springframework.stereotype.Repository
@Repository @Repository
class ExposedFilterRepository(private val filterQueryMapper: QueryMapper<Filter>) : FilterRepository, class ExposedFilterRepository(private val filterQueryMapper: QueryMapper<Filter>) : FilterRepository,
AbstractRepository() { AbstractRepository() {
override val logger: Logger
get() = Companion.logger
override suspend fun save(filter: Filter): Filter = query { override suspend fun save(filter: Filter): Filter = query {
Filters.upsert { Filters.upsert {
it[id] = filter.id.id it[id] = filter.id.id
@ -69,9 +72,6 @@ class ExposedFilterRepository(private val filterQueryMapper: QueryMapper<Filter>
return filterQueryMapper.map(where).firstOrNull() return filterQueryMapper.map(where).firstOrNull()
} }
override val logger: Logger
get() = Companion.logger
companion object { companion object {
private val logger = LoggerFactory.getLogger(ExposedFilterRepository::class.java) private val logger = LoggerFactory.getLogger(ExposedFilterRepository::class.java)
} }

View File

@ -52,6 +52,8 @@ class ExposedPostRepository(
PostRepository, PostRepository,
AbstractRepository(), AbstractRepository(),
DomainEventPublishableRepository<Post> { DomainEventPublishableRepository<Post> {
override val logger: Logger = Companion.logger
override suspend fun save(post: Post): Post { override suspend fun save(post: Post): Post {
query { query {
Posts.upsert { Posts.upsert {
@ -176,8 +178,6 @@ class ExposedPostRepository(
update(post) update(post)
} }
override val logger: Logger = Companion.logger
companion object { companion object {
private val logger = LoggerFactory.getLogger(ExposedPostRepository::class.java) private val logger = LoggerFactory.getLogger(ExposedPostRepository::class.java)
} }
@ -186,9 +186,9 @@ class ExposedPostRepository(
object Posts : Table("posts") { object Posts : Table("posts") {
val id = long("id") val id = long("id")
val actorId = long("actor_id").references(Actors.id) val actorId = long("actor_id").references(Actors.id)
val overview = varchar("overview", PostOverview.length).nullable() val overview = varchar("overview", PostOverview.LENGTH).nullable()
val content = varchar("content", PostContent.contentLength) val content = varchar("content", PostContent.CONTENT_LENGTH)
val text = varchar("text", PostContent.textLength) val text = varchar("text", PostContent.TEXT_LENGTH)
val createdAt = timestamp("created_at") val createdAt = timestamp("created_at")
val visibility = varchar("visibility", 100) val visibility = varchar("visibility", 100)
val url = varchar("url", 1000) val url = varchar("url", 1000)

View File

@ -32,6 +32,9 @@ class ExposedRelationshipRepository(override val domainEventPublisher: DomainEve
RelationshipRepository, RelationshipRepository,
AbstractRepository(), AbstractRepository(),
DomainEventPublishableRepository<Relationship> { DomainEventPublishableRepository<Relationship> {
override val logger: Logger
get() = Companion.logger
override suspend fun save(relationship: Relationship): Relationship { override suspend fun save(relationship: Relationship): Relationship {
query { query {
Relationships.upsert { Relationships.upsert {
@ -63,9 +66,6 @@ class ExposedRelationshipRepository(override val domainEventPublisher: DomainEve
}.singleOrNull()?.toRelationships() }.singleOrNull()?.toRelationships()
} }
override val logger: Logger
get() = Companion.logger
companion object { companion object {
private val logger = LoggerFactory.getLogger(ExposedRelationshipRepository::class.java) private val logger = LoggerFactory.getLogger(ExposedRelationshipRepository::class.java)
} }

View File

@ -27,6 +27,9 @@ import dev.usbharu.hideout.core.domain.model.media.Media as EntityMedia
@Repository @Repository
class MediaRepositoryImpl : MediaRepository, AbstractRepository() { 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? { override suspend fun findById(id: MediaId): dev.usbharu.hideout.core.domain.model.media.Media? {
return query { return query {
return@query Media 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 { override suspend fun save(media: EntityMedia): EntityMedia = query {
if (Media.selectAll().where { Media.id eq media.id.id }.forUpdate().singleOrNull() != null if (Media.selectAll().where { Media.id eq media.id.id }.forUpdate().singleOrNull() != null
) { ) {

View File

@ -26,7 +26,8 @@ class LocalFileSystemMediaStore(
val fileSavePathString = fileSavePath.toAbsolutePath().toString() val fileSavePathString = fileSavePath.toAbsolutePath().toString()
logger.info("MEDIA save. path: {}", fileSavePathString) logger.info("MEDIA save. path: {}", fileSavePathString)
@Suppress("TooGenericExceptionCaught") try { @Suppress("TooGenericExceptionCaught")
try {
path.copyTo(fileSavePath) path.copyTo(fileSavePath)
} catch (e: Exception) { } catch (e: Exception) {
logger.warn("FAILED to Save the media.", e) 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) private fun buildSavePath(savePath: Path, name: String): Path = savePath.resolve(name)
companion object { companion object {
private val logger = LoggerFactory.getLogger(LocalFileSystemMediaStore::class.java) private val logger = LoggerFactory.getLogger(LocalFileSystemMediaStore::class.java)
} }
} }

View File

@ -6,7 +6,5 @@ import java.awt.image.BufferedImage
@Component @Component
class GenerateBlurhashImpl : GenerateBlurhash { class GenerateBlurhashImpl : GenerateBlurhash {
override fun generateBlurhash(bufferedImage: BufferedImage): String { override fun generateBlurhash(bufferedImage: BufferedImage): String = BlurHash.encode(bufferedImage)
return BlurHash.encode(bufferedImage)
}
} }

View File

@ -25,9 +25,8 @@ class ImageIOImageProcessor(
private val imageIOImageConfig: ImageIOImageConfig, private val imageIOImageConfig: ImageIOImageConfig,
private val blurhash: GenerateBlurhash private val blurhash: GenerateBlurhash
) : MediaProcessor { ) : MediaProcessor {
override fun isSupported(mimeType: MimeType): Boolean { override fun isSupported(mimeType: MimeType): Boolean =
return mimeType.fileType == FileType.Image || mimeType.type == "image" mimeType.fileType == FileType.Image || mimeType.type == "image"
}
override suspend fun process(path: Path, filename: String, mimeType: MimeType?): ProcessedMedia { override suspend fun process(path: Path, filename: String, mimeType: MimeType?): ProcessedMedia {
val read = ImageIO.read(path.inputStream()) val read = ImageIO.read(path.inputStream())

View File

@ -25,9 +25,8 @@ class FFmpegVideoProcessor(
private val fFmpegVideoConfig: FFmpegVideoConfig, private val fFmpegVideoConfig: FFmpegVideoConfig,
private val generateBlurhash: GenerateBlurhash private val generateBlurhash: GenerateBlurhash
) : MediaProcessor { ) : MediaProcessor {
override fun isSupported(mimeType: MimeType): Boolean { override fun isSupported(mimeType: MimeType): Boolean =
return mimeType.fileType == FileType.Video || mimeType.type == "video" mimeType.fileType == FileType.Video || mimeType.type == "video"
}
override suspend fun process(path: Path, filename: String, mimeType: MimeType?): ProcessedMedia { override suspend fun process(path: Path, filename: String, mimeType: MimeType?): ProcessedMedia {
val tempFile = Files.createTempFile("hideout-movie-processor-", ".tmp") val tempFile = Files.createTempFile("hideout-movie-processor-", ".tmp")
@ -74,7 +73,6 @@ class FFmpegVideoProcessor(
it.videoBitrate = videoBitRate it.videoBitrate = videoBitRate
it.start() it.start()
val frameConverter = Java2DFrameConverter() val frameConverter = Java2DFrameConverter()
while (true) { while (true) {

View File

@ -23,7 +23,5 @@ open class HttpCommandExecutor(
val ip: String, val ip: String,
val userAgent: String, val userAgent: String,
) : CommandExecutor { ) : CommandExecutor {
override fun toString(): String { override fun toString(): String = "HttpCommandExecutor(executor='$executor', ip='$ip', userAgent='$userAgent')"
return "HttpCommandExecutor(executor='$executor', ip='$ip', userAgent='$userAgent')"
}
} }

View File

@ -24,7 +24,5 @@ class SpringSecurityPasswordEncoder(
private val passwordEncoder: org.springframework.security.crypto.password.PasswordEncoder, private val passwordEncoder: org.springframework.security.crypto.password.PasswordEncoder,
) : ) :
PasswordEncoder { PasswordEncoder {
override suspend fun encode(input: String): String { override suspend fun encode(input: String): String = passwordEncoder.encode(input)
return passwordEncoder.encode(input)
}
} }

View File

@ -40,17 +40,11 @@ class HideoutUserDetails(
val userDetailsId: Long, val userDetailsId: Long,
) : UserDetails { ) : UserDetails {
private val authorities: MutableSet<GrantedAuthority> = Collections.unmodifiableSet(authorities) private val authorities: MutableSet<GrantedAuthority> = Collections.unmodifiableSet(authorities)
override fun getAuthorities(): MutableSet<GrantedAuthority> { override fun getAuthorities(): MutableSet<GrantedAuthority> = authorities
return authorities
}
override fun getPassword(): String { override fun getPassword(): String = password
return password
}
override fun getUsername(): String { override fun getUsername(): String = username
return username
}
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true
@ -75,7 +69,12 @@ class HideoutUserDetails(
} }
override fun toString(): String { 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 { companion object {

View File

@ -32,6 +32,7 @@ class AuthController(
private val springMvcCommandExecutorFactory: SpringMvcCommandExecutorFactory, private val springMvcCommandExecutorFactory: SpringMvcCommandExecutorFactory,
) { ) {
@GetMapping("/auth/sign_up") @GetMapping("/auth/sign_up")
@Suppress("FunctionOnlyReturningConstant")
fun signUp(): String = "sign_up" fun signUp(): String = "sign_up"
@PostMapping("/auth/sign_up") @PostMapping("/auth/sign_up")

View File

@ -16,7 +16,7 @@ class ActorsTest {
actor.suspend = true actor.suspend = true
assertContainsEvent(actor, ActorEvent.actorSuspend.eventName) assertContainsEvent(actor, ActorEvent.ACTOR_SUSPEND.eventName)
} }
@Test @Test
@ -25,7 +25,7 @@ class ActorsTest {
actor.suspend = false actor.suspend = false
assertContainsEvent(actor, ActorEvent.actorUnsuspend.eventName) assertContainsEvent(actor, ActorEvent.ACTOR_UNSUSPEND.eventName)
} }
@Test @Test
@ -45,7 +45,7 @@ class ActorsTest {
actor.moveTo = ActorId(100) actor.moveTo = ActorId(100)
assertContainsEvent(actor, ActorEvent.move.eventName) assertContainsEvent(actor, ActorEvent.MOVE.eventName)
} }
@Test @Test
@ -72,7 +72,7 @@ class ActorsTest {
actor.description = ActorDescription("hoge fuga") actor.description = ActorDescription("hoge fuga")
assertContainsEvent(actor, ActorEvent.update.eventName) assertContainsEvent(actor, ActorEvent.UPDATE.eventName)
} }
@Test @Test
@ -81,7 +81,7 @@ class ActorsTest {
actor.screenName = ActorScreenName("fuga hoge") actor.screenName = ActorScreenName("fuga hoge")
assertContainsEvent(actor, ActorEvent.update.eventName) assertContainsEvent(actor, ActorEvent.UPDATE.eventName)
} }
@Test @Test
@ -106,7 +106,7 @@ class ActorsTest {
assertEquals(ActorPostsCount.ZERO, actor.postsCount) assertEquals(ActorPostsCount.ZERO, actor.postsCount)
assertNull(actor.followersCount) assertNull(actor.followersCount)
assertNull(actor.followingCount) assertNull(actor.followingCount)
assertContainsEvent(actor, ActorEvent.delete.eventName) assertContainsEvent(actor, ActorEvent.DELETE.eventName)
} }
@Test @Test
@ -116,7 +116,7 @@ class ActorsTest {
actor.restore() actor.restore()
assertFalse(actor.deleted) assertFalse(actor.deleted)
assertContainsEvent(actor, ActorEvent.checkUpdate.eventName) assertContainsEvent(actor, ActorEvent.CHECK_UPDATE.eventName)
} }
@Test @Test
@ -125,6 +125,6 @@ class ActorsTest {
actor.checkUpdate() actor.checkUpdate()
assertContainsEvent(actor, ActorEvent.checkUpdate.eventName) assertContainsEvent(actor, ActorEvent.CHECK_UPDATE.eventName)
} }
} }

View File

@ -137,7 +137,7 @@ class PostTest {
val actor = TestActorFactory.create(id = post.actorId.id, publicKey = ActorPublicKey("")) val actor = TestActorFactory.create(id = post.actorId.id, publicKey = ActorPublicKey(""))
post.setVisibility(Visibility.PUBLIC, actor) post.setVisibility(Visibility.PUBLIC, actor)
assertContainsEvent(post, PostEvent.update.eventName) assertContainsEvent(post, PostEvent.UPDATE.eventName)
} }
@Test @Test
@ -189,7 +189,7 @@ class PostTest {
val actor = TestActorFactory.create(id = post.actorId.id, publicKey = ActorPublicKey("")) val actor = TestActorFactory.create(id = post.actorId.id, publicKey = ActorPublicKey(""))
post.setVisibleActors(setOf(ActorId(100)), actor) post.setVisibleActors(setOf(ActorId(100)), actor)
assertContainsEvent(post, PostEvent.update.eventName) assertContainsEvent(post, PostEvent.UPDATE.eventName)
} }
@Test @Test
@ -213,7 +213,7 @@ class PostTest {
val post = TestPostFactory.create() val post = TestPostFactory.create()
val actor = TestActorFactory.create(id = post.actorId.id, publicKey = ActorPublicKey("")) val actor = TestActorFactory.create(id = post.actorId.id, publicKey = ActorPublicKey(""))
post.setContent(PostContent("test", "test", emptyList()), actor) post.setContent(PostContent("test", "test", emptyList()), actor)
assertContainsEvent(post, PostEvent.update.eventName) assertContainsEvent(post, PostEvent.UPDATE.eventName)
} }
@Test @Test
@ -249,7 +249,7 @@ class PostTest {
} }
assertEquals(overview, post.overview) assertEquals(overview, post.overview)
assertContainsEvent(post, PostEvent.update.eventName) assertContainsEvent(post, PostEvent.UPDATE.eventName)
} }
@Test @Test

View File

@ -42,11 +42,11 @@ class GetFilterV1ApplicationService(private val filterRepository: FilterReposito
phrase = filterKeyword?.keyword?.keyword, phrase = filterKeyword?.keyword?.keyword,
context = filter.filterContext.map { context = filter.filterContext.map {
when (it) { when (it) {
home -> V1Filter.Context.home HOME -> V1Filter.Context.home
notifications -> V1Filter.Context.notifications NOTIFICATION -> V1Filter.Context.notifications
public -> V1Filter.Context.public PUBLIC -> V1Filter.Context.public
thread -> V1Filter.Context.thread THREAD -> V1Filter.Context.thread
account -> V1Filter.Context.account ACCOUNT -> V1Filter.Context.account
} }
}, },
expiresAt = null, expiresAt = null,

View File

@ -82,16 +82,16 @@ class SpringFilterApi(
} }
val filterContext = v1FilterPostRequest.context.map { val filterContext = v1FilterPostRequest.context.map {
when (it) { when (it) {
home -> FilterContext.home home -> FilterContext.HOME
notifications -> FilterContext.notifications notifications -> FilterContext.NOTIFICATION
public -> FilterContext.public public -> FilterContext.PUBLIC
thread -> FilterContext.thread thread -> FilterContext.THREAD
account -> FilterContext.account account -> FilterContext.ACCOUNT
} }
}.toSet() }.toSet()
val filter = userRegisterFilterApplicationService.execute( val filter = userRegisterFilterApplicationService.execute(
RegisterFilter( RegisterFilter(
v1FilterPostRequest.phrase, filterContext, FilterAction.warn, v1FilterPostRequest.phrase, filterContext, FilterAction.WARN,
setOf(RegisterFilterKeyword(v1FilterPostRequest.phrase, filterMode)) setOf(RegisterFilterKeyword(v1FilterPostRequest.phrase, filterMode))
), executor ), executor
) )
@ -140,17 +140,17 @@ class SpringFilterApi(
title = filter.name, title = filter.name,
context = filter.filterContext.map { context = filter.filterContext.map {
when (it) { when (it) {
FilterContext.home -> Filter.Context.home FilterContext.HOME -> Filter.Context.home
FilterContext.notifications -> Filter.Context.notifications FilterContext.NOTIFICATION -> Filter.Context.notifications
FilterContext.public -> Filter.Context.public FilterContext.PUBLIC -> Filter.Context.public
FilterContext.thread -> Filter.Context.thread FilterContext.THREAD -> Filter.Context.thread
FilterContext.account -> Filter.Context.account FilterContext.ACCOUNT -> Filter.Context.account
} }
}, },
expiresAt = null, expiresAt = null,
filterAction = when (filter.filterAction) { filterAction = when (filter.filterAction) {
FilterAction.warn -> Filter.FilterAction.warn FilterAction.WARN -> Filter.FilterAction.warn
FilterAction.hide -> Filter.FilterAction.hide FilterAction.HIDE -> Filter.FilterAction.hide
}, },
keywords = filter.filterKeywords.map { keywords = filter.filterKeywords.map {
@ -197,17 +197,17 @@ class SpringFilterApi(
filterName = filterPostRequest.title, filterName = filterPostRequest.title,
filterContext = filterPostRequest.context.map { filterContext = filterPostRequest.context.map {
when (it) { when (it) {
Context.home -> FilterContext.home Context.home -> FilterContext.HOME
Context.notifications -> FilterContext.notifications Context.notifications -> FilterContext.NOTIFICATION
Context.public -> FilterContext.public Context.public -> FilterContext.PUBLIC
Context.thread -> FilterContext.thread Context.thread -> FilterContext.THREAD
Context.account -> FilterContext.account Context.account -> FilterContext.ACCOUNT
} }
}.toSet(), }.toSet(),
filterAction = when (filterPostRequest.filterAction) { filterAction = when (filterPostRequest.filterAction) {
FilterPostRequest.FilterAction.warn -> FilterAction.warn FilterPostRequest.FilterAction.warn -> FilterAction.WARN
FilterPostRequest.FilterAction.hide -> FilterAction.hide FilterPostRequest.FilterAction.hide -> FilterAction.HIDE
null -> FilterAction.warn null -> FilterAction.WARN
}, },
filterKeywords = filterPostRequest.keywordsAttributes.orEmpty().map { filterKeywords = filterPostRequest.keywordsAttributes.orEmpty().map {
RegisterFilterKeyword( RegisterFilterKeyword(