mirror of https://github.com/usbharu/Hideout.git
style: fix lint
This commit is contained in:
parent
0b062b6a68
commit
446b87e3d9
|
@ -47,23 +47,23 @@ data class UserDetail(
|
|||
customEmojis: List<CustomEmoji>,
|
||||
): 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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,4 +46,4 @@ data class Filter(
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ import org.springframework.stereotype.Service
|
|||
@Service
|
||||
class UserDeleteFilterApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) :
|
||||
AbstractApplicationService<DeleteFilter, Unit>(
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ import org.springframework.stereotype.Service
|
|||
@Service
|
||||
class UserGetFilterApplicationService(private val filterRepository: FilterRepository, transaction: Transaction) :
|
||||
AbstractApplicationService<GetFilter, Filter>(
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ class UserRegisterFilterApplicationService(
|
|||
transaction: Transaction,
|
||||
) :
|
||||
AbstractApplicationService<RegisterFilter, Filter>(
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,8 @@ class UploadMediaApplicationService(
|
|||
private val idGenerateService: IdGenerateService,
|
||||
transaction: Transaction
|
||||
) : AbstractApplicationService<UploadMedia, Media>(
|
||||
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)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,4 +14,4 @@ data class FFmpegVideoConfig(
|
|||
val videoQuality: Double = 1.0,
|
||||
val videoOption: List<String> = listOf("preset", "ultrafast"),
|
||||
val maxBitrate: Int = 1300000,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -14,4 +14,4 @@ import org.springframework.boot.context.properties.ConfigurationProperties
|
|||
data class LocalStorageConfig(
|
||||
val path: String = "files",
|
||||
val publicUrl: String?
|
||||
)
|
||||
)
|
||||
|
|
|
@ -31,4 +31,4 @@ class AwsConfig {
|
|||
.credentialsProvider { AwsBasicCredentials.create(awsConfig.accessKey, awsConfig.secretKey) }
|
||||
.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"),
|
||||
}
|
||||
|
|
|
@ -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"),
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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"),
|
||||
}
|
||||
|
|
|
@ -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"),
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -41,12 +41,12 @@ class Filter(
|
|||
|
||||
fun reconstructWith(filterKeywords: Set<FilterKeyword>): 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,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package dev.usbharu.hideout.core.domain.model.filter
|
||||
|
||||
enum class FilterAction {
|
||||
warn,
|
||||
hide
|
||||
WARN,
|
||||
HIDE
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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<MediaId>, 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<MediaId>) {
|
||||
|
@ -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<MediaId>, emojis: List<EmojiId>, visibleActors: Set<ActorId>): 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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
package dev.usbharu.hideout.core.domain.shared.domainevent
|
||||
|
||||
@Suppress("UnnecessaryAbstractClass")
|
||||
abstract class DomainEventBody(val map: Map<String, Any?>) {
|
||||
fun toMap(): Map<String, Any?> {
|
||||
return map
|
||||
}
|
||||
fun toMap(): Map<String, Any?> = map
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package dev.usbharu.hideout.core.domain.shared.domainevent
|
||||
|
||||
@Suppress("UnnecessaryAbstractClass")
|
||||
abstract class DomainEventStorable {
|
||||
private val domainEvents: MutableList<DomainEvent> = mutableListOf()
|
||||
|
||||
|
|
|
@ -11,12 +11,10 @@ class DelegateMediaProcessor(
|
|||
private val fileTypeDeterminer: FileTypeDeterminer,
|
||||
private val mediaProcessors: List<MediaProcessor>
|
||||
) : 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,4 +5,4 @@ import java.nio.file.Path
|
|||
|
||||
interface FileTypeDeterminer {
|
||||
fun fileType(path: Path, filename: String): MimeType
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,4 +48,4 @@ class TikaFileTypeDeterminer : FileTypeDeterminer {
|
|||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(TikaFileTypeDeterminer::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,4 +5,4 @@ import java.nio.file.Path
|
|||
|
||||
interface MediaStore {
|
||||
suspend fun upload(path: Path, id: String): URI
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,17 +34,20 @@ class FilterQueryMapper(private val filterResultRowMapper: ResultRowMapper<Filte
|
|||
.first()
|
||||
.let(filterResultRowMapper::map)
|
||||
.apply {
|
||||
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())
|
||||
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()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,4 +32,4 @@ class FilterResultRowMapper : ResultRowMapper<Filter> {
|
|||
FilterAction.valueOf(resultRow[Filters.filterAction]),
|
||||
emptySet()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,9 @@ class ExposedActorInstanceRelationshipRepository(override val domainEventPublish
|
|||
ActorInstanceRelationshipRepository,
|
||||
AbstractRepository(),
|
||||
DomainEventPublishableRepository<ActorInstanceRelationship> {
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -30,6 +30,9 @@ import org.springframework.stereotype.Repository
|
|||
@Repository
|
||||
class ExposedFilterRepository(private val filterQueryMapper: QueryMapper<Filter>) : 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<Filter>
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,8 @@ class ExposedPostRepository(
|
|||
PostRepository,
|
||||
AbstractRepository(),
|
||||
DomainEventPublishableRepository<Post> {
|
||||
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)
|
||||
|
|
|
@ -32,6 +32,9 @@ class ExposedRelationshipRepository(override val domainEventPublisher: DomainEve
|
|||
RelationshipRepository,
|
||||
AbstractRepository(),
|
||||
DomainEventPublishableRepository<Relationship> {
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,4 +4,4 @@ import java.awt.image.BufferedImage
|
|||
|
||||
interface GenerateBlurhash {
|
||||
fun generateBlurhash(bufferedImage: BufferedImage): String
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,5 @@ import java.awt.image.BufferedImage
|
|||
|
||||
@Component
|
||||
class GenerateBlurhashImpl : GenerateBlurhash {
|
||||
override fun generateBlurhash(bufferedImage: BufferedImage): String {
|
||||
return BlurHash.encode(bufferedImage)
|
||||
}
|
||||
}
|
||||
override fun generateBlurhash(bufferedImage: BufferedImage): String = BlurHash.encode(bufferedImage)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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')"
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -40,17 +40,11 @@ class HideoutUserDetails(
|
|||
val userDetailsId: Long,
|
||||
) : UserDetails {
|
||||
private val authorities: MutableSet<GrantedAuthority> = Collections.unmodifiableSet(authorities)
|
||||
override fun getAuthorities(): MutableSet<GrantedAuthority> {
|
||||
return authorities
|
||||
}
|
||||
override fun getAuthorities(): MutableSet<GrantedAuthority> = 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 {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue