mirror of https://github.com/usbharu/Hideout.git
style: fix lint
This commit is contained in:
parent
b8402b0264
commit
c866705b92
|
@ -133,6 +133,8 @@ naming:
|
||||||
- "**/test/**"
|
- "**/test/**"
|
||||||
|
|
||||||
FunctionMinLength:
|
FunctionMinLength:
|
||||||
|
ignoreFunction:
|
||||||
|
- of
|
||||||
active: true
|
active: true
|
||||||
|
|
||||||
LambdaParameterNaming:
|
LambdaParameterNaming:
|
||||||
|
|
|
@ -33,10 +33,6 @@ class GetUserDetailApplicationService(
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<GetUserDetail, UserDetail>(transaction, Companion.logger) {
|
AbstractApplicationService<GetUserDetail, UserDetail>(transaction, Companion.logger) {
|
||||||
companion object {
|
|
||||||
val logger = LoggerFactory.getLogger(GetUserDetailApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun internalExecute(command: GetUserDetail, executor: CommandExecutor): UserDetail {
|
override suspend fun internalExecute(command: GetUserDetail, executor: CommandExecutor): UserDetail {
|
||||||
val userDetail = userDetailRepository.findById(command.id)
|
val userDetail = userDetailRepository.findById(command.id)
|
||||||
?: throw IllegalArgumentException("actor does not exist")
|
?: throw IllegalArgumentException("actor does not exist")
|
||||||
|
@ -46,4 +42,8 @@ class GetUserDetailApplicationService(
|
||||||
|
|
||||||
return UserDetail.of(actor, userDetail, emojis)
|
return UserDetail.of(actor, userDetail, emojis)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val logger = LoggerFactory.getLogger(GetUserDetailApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,12 @@ class UserDeleteFilterApplicationService(private val filterRepository: FilterRep
|
||||||
transaction,
|
transaction,
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
companion object {
|
|
||||||
private val logger = LoggerFactory.getLogger(UserDeleteFilterApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun internalExecute(command: DeleteFilter, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: DeleteFilter, executor: CommandExecutor) {
|
||||||
val filter = filterRepository.findByFilterId(FilterId(command.filterId)) ?: throw Exception("not found")
|
val filter = filterRepository.findByFilterId(FilterId(command.filterId)) ?: throw Exception("not found")
|
||||||
filterRepository.delete(filter)
|
filterRepository.delete(filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val logger = LoggerFactory.getLogger(UserDeleteFilterApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,6 @@ class UserRegisterFilterApplicationService(
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val logger = LoggerFactory.getLogger(UserRegisterFilterApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
@ -64,4 +60,8 @@ class UserRegisterFilterApplicationService(
|
||||||
filterRepository.save(filter)
|
filterRepository.save(filter)
|
||||||
return Filter.of(filter)
|
return Filter.of(filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val logger = LoggerFactory.getLogger(UserRegisterFilterApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,6 @@ class UploadMediaApplicationService(
|
||||||
transaction,
|
transaction,
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
companion object {
|
|
||||||
private val logger = LoggerFactory.getLogger(UploadMediaApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun internalExecute(command: UploadMedia, executor: CommandExecutor): Media {
|
override suspend fun internalExecute(command: UploadMedia, executor: CommandExecutor): Media {
|
||||||
val process = mediaProcessor.process(command.path, command.name, null)
|
val process = mediaProcessor.process(command.path, command.name, null)
|
||||||
val id = idGenerateService.generateId()
|
val id = idGenerateService.generateId()
|
||||||
|
@ -69,4 +65,8 @@ class UploadMediaApplicationService(
|
||||||
|
|
||||||
return Media.of(media)
|
return Media.of(media)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val logger = LoggerFactory.getLogger(UploadMediaApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,6 @@ class RegisterLocalPostApplicationService(
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
) : AbstractApplicationService<RegisterLocalPost, Long>(transaction, Companion.logger) {
|
) : AbstractApplicationService<RegisterLocalPost, Long>(transaction, Companion.logger) {
|
||||||
|
|
||||||
companion object {
|
|
||||||
val logger: Logger = LoggerFactory.getLogger(RegisterLocalPostApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun internalExecute(command: RegisterLocalPost, executor: CommandExecutor): Long {
|
override suspend fun internalExecute(command: RegisterLocalPost, executor: CommandExecutor): Long {
|
||||||
val actorId = (
|
val actorId = (
|
||||||
userDetailRepository.findById(command.userDetailId)
|
userDetailRepository.findById(command.userDetailId)
|
||||||
|
@ -67,4 +63,8 @@ class RegisterLocalPostApplicationService(
|
||||||
|
|
||||||
return post.id.id
|
return post.id.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val logger: Logger = LoggerFactory.getLogger(RegisterLocalPostApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,6 @@ class UserAcceptFollowRequestApplicationService(
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<AcceptFollowRequest, Unit>(transaction, logger) {
|
AbstractApplicationService<AcceptFollowRequest, Unit>(transaction, logger) {
|
||||||
companion object {
|
|
||||||
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun internalExecute(command: AcceptFollowRequest, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: AcceptFollowRequest, executor: CommandExecutor) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
require(executor is UserDetailGettableCommandExecutor)
|
||||||
|
|
||||||
|
@ -55,4 +51,8 @@ class UserAcceptFollowRequestApplicationService(
|
||||||
|
|
||||||
relationshipRepository.save(relationship)
|
relationshipRepository.save(relationship)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,6 @@ class UserBlockApplicationService(
|
||||||
private val relationshipDomainService: RelationshipDomainService,
|
private val relationshipDomainService: RelationshipDomainService,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<Block, Unit>(transaction, logger) {
|
AbstractApplicationService<Block, Unit>(transaction, logger) {
|
||||||
companion object {
|
|
||||||
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun internalExecute(command: Block, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: Block, executor: CommandExecutor) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
require(executor is UserDetailGettableCommandExecutor)
|
||||||
|
|
||||||
|
@ -65,4 +61,8 @@ class UserBlockApplicationService(
|
||||||
relationshipRepository.save(relationship)
|
relationshipRepository.save(relationship)
|
||||||
relationshipRepository.save(inverseRelationship)
|
relationshipRepository.save(inverseRelationship)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,6 @@ class GetRelationshipApplicationService(
|
||||||
transaction,
|
transaction,
|
||||||
logger
|
logger
|
||||||
) {
|
) {
|
||||||
companion object {
|
|
||||||
private val logger = LoggerFactory.getLogger(GetRelationshipApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun internalExecute(command: GetRelationship, executor: CommandExecutor): Relationship {
|
override suspend fun internalExecute(command: GetRelationship, executor: CommandExecutor): Relationship {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
require(executor is UserDetailGettableCommandExecutor)
|
||||||
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
val userDetail = userDetailRepository.findById(executor.userDetailId)!!
|
||||||
|
@ -70,4 +66,8 @@ class GetRelationshipApplicationService(
|
||||||
|
|
||||||
return Relationship.of(relationship, relationship1, actorInstanceRelationship)
|
return Relationship.of(relationship, relationship1, actorInstanceRelationship)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val logger = LoggerFactory.getLogger(GetRelationshipApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,6 @@ class UserMuteApplicationService(
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<Mute, Unit>(transaction, logger) {
|
AbstractApplicationService<Mute, Unit>(transaction, logger) {
|
||||||
companion object {
|
|
||||||
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun internalExecute(command: Mute, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: Mute, executor: CommandExecutor) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
require(executor is UserDetailGettableCommandExecutor)
|
||||||
|
|
||||||
|
@ -57,4 +53,8 @@ class UserMuteApplicationService(
|
||||||
|
|
||||||
relationshipRepository.save(relationship)
|
relationshipRepository.save(relationship)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,6 @@ class UserRejectFollowRequestApplicationService(
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<RejectFollowRequest, Unit>(transaction, logger) {
|
AbstractApplicationService<RejectFollowRequest, Unit>(transaction, logger) {
|
||||||
companion object {
|
|
||||||
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun internalExecute(command: RejectFollowRequest, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: RejectFollowRequest, executor: CommandExecutor) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
require(executor is UserDetailGettableCommandExecutor)
|
||||||
|
|
||||||
|
@ -55,4 +51,8 @@ class UserRejectFollowRequestApplicationService(
|
||||||
|
|
||||||
relationshipRepository.save(relationship)
|
relationshipRepository.save(relationship)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,6 @@ class UserRemoveFromFollowersApplicationService(
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<RemoveFromFollowers, Unit>(transaction, logger) {
|
AbstractApplicationService<RemoveFromFollowers, Unit>(transaction, logger) {
|
||||||
companion object {
|
|
||||||
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun internalExecute(command: RemoveFromFollowers, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: RemoveFromFollowers, executor: CommandExecutor) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
require(executor is UserDetailGettableCommandExecutor)
|
||||||
|
|
||||||
|
@ -57,4 +53,8 @@ class UserRemoveFromFollowersApplicationService(
|
||||||
|
|
||||||
relationshipRepository.save(relationship)
|
relationshipRepository.save(relationship)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,6 @@ class UserUnblockApplicationService(
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<Unblock, Unit>(transaction, logger) {
|
AbstractApplicationService<Unblock, Unit>(transaction, logger) {
|
||||||
companion object {
|
|
||||||
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun internalExecute(command: Unblock, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: Unblock, executor: CommandExecutor) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
require(executor is UserDetailGettableCommandExecutor)
|
||||||
|
|
||||||
|
@ -57,4 +53,8 @@ class UserUnblockApplicationService(
|
||||||
|
|
||||||
relationshipRepository.save(relationship)
|
relationshipRepository.save(relationship)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,6 @@ class UserUnfollowApplicationService(
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<Unfollow, Unit>(transaction, logger) {
|
AbstractApplicationService<Unfollow, Unit>(transaction, logger) {
|
||||||
companion object {
|
|
||||||
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun internalExecute(command: Unfollow, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: Unfollow, executor: CommandExecutor) {
|
||||||
require(executor is UserDetailGettableCommandExecutor)
|
require(executor is UserDetailGettableCommandExecutor)
|
||||||
|
|
||||||
|
@ -57,4 +53,8 @@ class UserUnfollowApplicationService(
|
||||||
|
|
||||||
relationshipRepository.save(relationship)
|
relationshipRepository.save(relationship)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val logger = LoggerFactory.getLogger(UserBlockApplicationService::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,7 @@ import org.springframework.security.web.authentication.LoginUrlAuthenticationEnt
|
||||||
@EnableWebSecurity(debug = true)
|
@EnableWebSecurity(debug = true)
|
||||||
class SecurityConfig {
|
class SecurityConfig {
|
||||||
@Bean
|
@Bean
|
||||||
fun passwordEncoder(): PasswordEncoder {
|
fun passwordEncoder(): PasswordEncoder = BCryptPasswordEncoder()
|
||||||
return BCryptPasswordEncoder()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Order(1)
|
@Order(1)
|
||||||
|
@ -93,17 +91,16 @@ class SecurityConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
fun registeredClientRepository(jdbcOperations: JdbcOperations): RegisteredClientRepository {
|
fun registeredClientRepository(jdbcOperations: JdbcOperations): RegisteredClientRepository =
|
||||||
return JdbcRegisteredClientRepository(jdbcOperations)
|
JdbcRegisteredClientRepository(jdbcOperations)
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@Suppress("FunctionMaxLength")
|
||||||
fun oauth2AuthorizationConsentService(
|
fun oauth2AuthorizationConsentService(
|
||||||
jdbcOperations: JdbcOperations,
|
jdbcOperations: JdbcOperations,
|
||||||
registeredClientRepository: RegisteredClientRepository,
|
registeredClientRepository: RegisteredClientRepository,
|
||||||
): OAuth2AuthorizationConsentService {
|
): OAuth2AuthorizationConsentService =
|
||||||
return JdbcOAuth2AuthorizationConsentService(jdbcOperations, registeredClientRepository)
|
JdbcOAuth2AuthorizationConsentService(jdbcOperations, registeredClientRepository)
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
fun authorizationServerSettings(): AuthorizationServerSettings {
|
fun authorizationServerSettings(): AuthorizationServerSettings {
|
||||||
|
|
|
@ -21,9 +21,8 @@ import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEvent
|
||||||
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventBody
|
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventBody
|
||||||
|
|
||||||
class RelationshipEventFactory(private val relationship: Relationship) {
|
class RelationshipEventFactory(private val relationship: Relationship) {
|
||||||
fun createEvent(relationshipEvent: RelationshipEvent): DomainEvent {
|
fun createEvent(relationshipEvent: RelationshipEvent): DomainEvent =
|
||||||
return DomainEvent.create(relationshipEvent.eventName, RelationshipEventBody(relationship))
|
DomainEvent.create(relationshipEvent.eventName, RelationshipEventBody(relationship))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class RelationshipEventBody(relationship: Relationship) : DomainEventBody(mapOf("relationship" to relationship))
|
class RelationshipEventBody(relationship: Relationship) : DomainEventBody(mapOf("relationship" to relationship))
|
||||||
|
|
|
@ -26,7 +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")
|
@Suppress("LongParameterList", "ClassOrdering")
|
||||||
class Actor(
|
class Actor(
|
||||||
val id: ActorId,
|
val id: ActorId,
|
||||||
val name: ActorName,
|
val name: ActorName,
|
||||||
|
@ -96,7 +96,7 @@ class Actor(
|
||||||
|
|
||||||
var alsoKnownAs = alsoKnownAs
|
var alsoKnownAs = alsoKnownAs
|
||||||
set(value) {
|
set(value) {
|
||||||
require(value.find { it == id } == null)
|
require(value.any { it == id })
|
||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
package dev.usbharu.hideout.core.domain.model.actor
|
package dev.usbharu.hideout.core.domain.model.actor
|
||||||
|
|
||||||
class ActorDescription(description: String) {
|
class ActorDescription(description: String) {
|
||||||
val description: String = description.take(length)
|
val description: String = description.take(LENGTH)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val length = 10000
|
const val LENGTH = 10000
|
||||||
val empty = ActorDescription("")
|
val empty = ActorDescription("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@ package dev.usbharu.hideout.core.domain.model.actor
|
||||||
value class ActorName(val name: String) {
|
value class ActorName(val name: String) {
|
||||||
init {
|
init {
|
||||||
require(name.isNotBlank())
|
require(name.isNotBlank())
|
||||||
require(name.length <= length)
|
require(name.length <= LENGTH)
|
||||||
require(regex.matches(name))
|
require(regex.matches(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val length = 300
|
const val LENGTH = 300
|
||||||
private val regex = Regex("^[a-zA-Z0-9_-]{1,$length}\$")
|
private val regex = Regex("^[a-zA-Z0-9_-]{1,$LENGTH}\$")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,10 @@ package dev.usbharu.hideout.core.domain.model.actor
|
||||||
|
|
||||||
class ActorScreenName(screenName: String) {
|
class ActorScreenName(screenName: String) {
|
||||||
|
|
||||||
val screenName: String = screenName.take(length)
|
val screenName: String = screenName.take(LENGTH)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val length = 300
|
const val LENGTH = 300
|
||||||
val empty = ActorScreenName("")
|
val empty = ActorScreenName("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,7 @@
|
||||||
package dev.usbharu.hideout.core.domain.model.filter
|
package dev.usbharu.hideout.core.domain.model.filter
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.domain.model.filter.FilterMode.*
|
|
||||||
|
|
||||||
class FilterKeyword(
|
class FilterKeyword(
|
||||||
val id: FilterKeywordId,
|
val id: FilterKeywordId,
|
||||||
var keyword: FilterKeywordKeyword,
|
var keyword: FilterKeywordKeyword,
|
||||||
val mode: FilterMode
|
val mode: FilterMode
|
||||||
) {
|
)
|
||||||
fun match(string: String): Boolean {
|
|
||||||
when (mode) {
|
|
||||||
WHOLE_WORD -> TODO()
|
|
||||||
REGEX -> TODO()
|
|
||||||
NONE -> TODO()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -53,7 +53,5 @@ class Instance(
|
||||||
return id == other.id
|
return id == other.id
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int = id.hashCode()
|
||||||
return id.hashCode()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +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")
|
@Suppress("LongParameterList", "TooManyFunctions", "ClassOrdering")
|
||||||
class Post(
|
class Post(
|
||||||
val id: PostId,
|
val id: PostId,
|
||||||
actorId: ActorId,
|
actorId: ActorId,
|
||||||
|
|
|
@ -21,6 +21,7 @@ import dev.usbharu.hideout.core.domain.event.relationship.RelationshipEventFacto
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable
|
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable
|
||||||
|
|
||||||
|
@Suppress("TooManyFunctions")
|
||||||
class Relationship(
|
class Relationship(
|
||||||
val actorId: ActorId,
|
val actorId: ActorId,
|
||||||
val targetActorId: ActorId,
|
val targetActorId: ActorId,
|
||||||
|
|
|
@ -35,7 +35,14 @@ class ActorQueryMapper(private val actorResultRowMapper: ResultRowMapper<Actor>)
|
||||||
.first()
|
.first()
|
||||||
.let(actorResultRowMapper::map)
|
.let(actorResultRowMapper::map)
|
||||||
.apply {
|
.apply {
|
||||||
alsoKnownAs = it.mapNotNull { resultRow: ResultRow ->
|
alsoKnownAs = buildAlsoKnownAs(it)
|
||||||
|
clearDomainEvents()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun buildAlsoKnownAs(it: List<ResultRow>) =
|
||||||
|
it.mapNotNull { resultRow: ResultRow ->
|
||||||
resultRow.getOrNull(
|
resultRow.getOrNull(
|
||||||
ActorsAlsoKnownAs.alsoKnownAs
|
ActorsAlsoKnownAs.alsoKnownAs
|
||||||
)?.let { actorId ->
|
)?.let { actorId ->
|
||||||
|
@ -44,8 +51,4 @@ class ActorQueryMapper(private val actorResultRowMapper: ResultRowMapper<Actor>)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}.toSet()
|
}.toSet()
|
||||||
clearDomainEvents()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,13 @@ import org.springframework.stereotype.Component
|
||||||
@Component
|
@Component
|
||||||
class FilterResultRowMapper : ResultRowMapper<Filter> {
|
class FilterResultRowMapper : ResultRowMapper<Filter> {
|
||||||
override fun map(resultRow: ResultRow): Filter = Filter(
|
override fun map(resultRow: ResultRow): Filter = Filter(
|
||||||
FilterId(resultRow[Filters.id]),
|
id = FilterId(resultRow[Filters.id]),
|
||||||
UserDetailId(resultRow[Filters.userId]),
|
userDetailId = UserDetailId(resultRow[Filters.userId]),
|
||||||
FilterName(resultRow[Filters.name]),
|
name = FilterName(resultRow[Filters.name]),
|
||||||
resultRow[Filters.context].split(",").filter { it.isNotEmpty() }.map { FilterContext.valueOf(it) }.toSet(),
|
filterContext = resultRow[Filters.context].split(",").filter {
|
||||||
FilterAction.valueOf(resultRow[Filters.filterAction]),
|
it.isNotEmpty()
|
||||||
emptySet()
|
}.map { FilterContext.valueOf(it) }.toSet(),
|
||||||
|
filterAction = FilterAction.valueOf(resultRow[Filters.filterAction]),
|
||||||
|
filterKeywords = emptySet()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,12 @@ class PostQueryMapper(private val postResultRowMapper: ResultRowMapper<Post>) :
|
||||||
.first()
|
.first()
|
||||||
.let(postResultRowMapper::map)
|
.let(postResultRowMapper::map)
|
||||||
.apply {
|
.apply {
|
||||||
|
buildPost(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Post.buildPost(it: List<ResultRow>) {
|
||||||
reconstructWith(
|
reconstructWith(
|
||||||
mediaIds = it.mapNotNull { resultRow: ResultRow ->
|
mediaIds = it.mapNotNull { resultRow: ResultRow ->
|
||||||
resultRow
|
resultRow
|
||||||
|
@ -59,5 +65,3 @@ class PostQueryMapper(private val postResultRowMapper: ResultRowMapper<Post>) :
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -105,10 +105,10 @@ class ExposedActorRepository(
|
||||||
|
|
||||||
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()
|
||||||
val outbox = varchar("outbox", 1000).uniqueIndex()
|
val outbox = varchar("outbox", 1000).uniqueIndex()
|
||||||
val url = varchar("url", 1000).uniqueIndex()
|
val url = varchar("url", 1000).uniqueIndex()
|
||||||
|
|
|
@ -34,12 +34,12 @@ class ExposedFilterRepository(private val filterQueryMapper: QueryMapper<Filter>
|
||||||
get() = Companion.logger
|
get() = Companion.logger
|
||||||
|
|
||||||
override suspend fun save(filter: Filter): Filter = query {
|
override suspend fun save(filter: Filter): Filter = query {
|
||||||
Filters.upsert {
|
Filters.upsert { upsertStatement ->
|
||||||
it[id] = filter.id.id
|
upsertStatement[id] = filter.id.id
|
||||||
it[userId] = filter.userDetailId.id
|
upsertStatement[userId] = filter.userDetailId.id
|
||||||
it[name] = filter.name.name
|
upsertStatement[name] = filter.name.name
|
||||||
it[context] = filter.filterContext.joinToString(",") { it.name }
|
upsertStatement[context] = filter.filterContext.joinToString(",") { it.name }
|
||||||
it[filterAction] = filter.filterAction.name
|
upsertStatement[filterAction] = filter.filterAction.name
|
||||||
}
|
}
|
||||||
FilterKeywords.deleteWhere {
|
FilterKeywords.deleteWhere {
|
||||||
filterId eq filter.id.id
|
filterId eq filter.id.id
|
||||||
|
|
|
@ -35,6 +35,7 @@ class PostFactoryImpl(
|
||||||
private val postContentFactoryImpl: PostContentFactoryImpl,
|
private val postContentFactoryImpl: PostContentFactoryImpl,
|
||||||
private val applicationConfig: ApplicationConfig,
|
private val applicationConfig: ApplicationConfig,
|
||||||
) {
|
) {
|
||||||
|
@Suppress("LongParameterList")
|
||||||
suspend fun createLocal(
|
suspend fun createLocal(
|
||||||
actor: Actor,
|
actor: Actor,
|
||||||
actorName: ActorName,
|
actorName: ActorName,
|
||||||
|
|
|
@ -28,6 +28,7 @@ class FFmpegVideoProcessor(
|
||||||
override fun isSupported(mimeType: MimeType): Boolean =
|
override fun isSupported(mimeType: MimeType): Boolean =
|
||||||
mimeType.fileType == FileType.Video || mimeType.type == "video"
|
mimeType.fileType == FileType.Video || mimeType.type == "video"
|
||||||
|
|
||||||
|
@Suppress("LongMethod", "CyclomaticComplexMethod", "CognitiveComplexMethod", "NestedBlockDepth")
|
||||||
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")
|
||||||
val thumbnailFile = Files.createTempFile("hideout-movie-thumbnail-generate-", ".tmp")
|
val thumbnailFile = Files.createTempFile("hideout-movie-thumbnail-generate-", ".tmp")
|
||||||
|
|
|
@ -8,6 +8,6 @@ class ActorScreenNameTest {
|
||||||
fun screenNameがlengthを超えると無視される() {
|
fun screenNameがlengthを超えると無視される() {
|
||||||
val actorScreenName = ActorScreenName("a".repeat(1000))
|
val actorScreenName = ActorScreenName("a".repeat(1000))
|
||||||
|
|
||||||
assertEquals(ActorScreenName.length, actorScreenName.screenName.length)
|
assertEquals(ActorScreenName.LENGTH, actorScreenName.screenName.length)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue