mirror of https://github.com/usbharu/Hideout.git
style: fix lint
This commit is contained in:
parent
5ab62d1250
commit
ea666cf0f8
|
@ -43,9 +43,7 @@ class RegisterApplicationApplicationService(
|
||||||
private val applicationRepository: ApplicationRepository,
|
private val applicationRepository: ApplicationRepository,
|
||||||
) {
|
) {
|
||||||
suspend fun register(registerApplication: RegisterApplication): RegisteredApplication {
|
suspend fun register(registerApplication: RegisterApplication): RegisteredApplication {
|
||||||
|
|
||||||
return transaction.transaction {
|
return transaction.transaction {
|
||||||
|
|
||||||
val id = idGenerateService.generateId()
|
val id = idGenerateService.generateId()
|
||||||
val clientSecret = secureTokenGenerator.generate()
|
val clientSecret = secureTokenGenerator.generate()
|
||||||
val registeredClient = RegisteredClient
|
val registeredClient = RegisteredClient
|
||||||
|
@ -89,6 +87,5 @@ class RegisterApplicationApplicationService(
|
||||||
redirectUris = registerApplication.redirectUris
|
redirectUris = registerApplication.redirectUris
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -44,8 +44,10 @@ class RegisterLocalPostApplicationService(
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun internalExecute(command: RegisterLocalPost, executor: CommandExecutor): Long {
|
override suspend fun internalExecute(command: RegisterLocalPost, executor: CommandExecutor): Long {
|
||||||
val actorId = (userDetailRepository.findById(command.userDetailId)
|
val actorId = (
|
||||||
?: throw IllegalStateException("actor not found")).actorId
|
userDetailRepository.findById(command.userDetailId)
|
||||||
|
?: throw IllegalStateException("actor not found")
|
||||||
|
).actorId
|
||||||
|
|
||||||
val actor = actorRepository.findById(actorId)!!
|
val actor = actorRepository.findById(actorId)!!
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,6 @@ class UserBlockApplicationService(
|
||||||
|
|
||||||
relationshipDomainService.block(relationship, inverseRelationship)
|
relationshipDomainService.block(relationship, inverseRelationship)
|
||||||
|
|
||||||
|
|
||||||
relationshipRepository.save(relationship)
|
relationshipRepository.save(relationship)
|
||||||
relationshipRepository.save(inverseRelationship)
|
relationshipRepository.save(inverseRelationship)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,8 @@ class UserFollowRequestApplicationService(
|
||||||
private val actorRepository: ActorRepository,
|
private val actorRepository: ActorRepository,
|
||||||
private val userDetailRepository: UserDetailRepository,
|
private val userDetailRepository: UserDetailRepository,
|
||||||
) : AbstractApplicationService<FollowRequest, Unit>(
|
) : AbstractApplicationService<FollowRequest, Unit>(
|
||||||
transaction, logger
|
transaction,
|
||||||
|
logger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override suspend fun internalExecute(command: FollowRequest, executor: CommandExecutor) {
|
override suspend fun internalExecute(command: FollowRequest, executor: CommandExecutor) {
|
||||||
|
|
|
@ -38,7 +38,8 @@ class GetRelationshipApplicationService(
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<GetRelationship, Relationship>(
|
AbstractApplicationService<GetRelationship, Relationship>(
|
||||||
transaction, logger
|
transaction,
|
||||||
|
logger
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
private val logger = LoggerFactory.getLogger(GetRelationshipApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(GetRelationshipApplicationService::class.java)
|
||||||
|
@ -50,11 +51,15 @@ class GetRelationshipApplicationService(
|
||||||
val actor = actorRepository.findById(userDetail.actorId)!!
|
val actor = actorRepository.findById(userDetail.actorId)!!
|
||||||
val targetId = ActorId(command.targetActorId)
|
val targetId = ActorId(command.targetActorId)
|
||||||
val target = actorRepository.findById(targetId)!!
|
val target = actorRepository.findById(targetId)!!
|
||||||
val relationship = (relationshipRepository.findByActorIdAndTargetId(actor.id, targetId)
|
val relationship = (
|
||||||
?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(actor.id, targetId))
|
relationshipRepository.findByActorIdAndTargetId(actor.id, targetId)
|
||||||
|
?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(actor.id, targetId)
|
||||||
|
)
|
||||||
|
|
||||||
val relationship1 = (relationshipRepository.findByActorIdAndTargetId(targetId, actor.id)
|
val relationship1 = (
|
||||||
?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(targetId, actor.id))
|
relationshipRepository.findByActorIdAndTargetId(targetId, actor.id)
|
||||||
|
?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(targetId, actor.id)
|
||||||
|
)
|
||||||
|
|
||||||
val actorInstanceRelationship =
|
val actorInstanceRelationship =
|
||||||
actorInstanceRelationshipRepository.findByActorIdAndInstanceId(actor.id, target.instance)
|
actorInstanceRelationshipRepository.findByActorIdAndInstanceId(actor.id, target.instance)
|
||||||
|
|
|
@ -38,7 +38,6 @@ abstract class AbstractApplicationService<T : Any, R>(
|
||||||
logger.warn("Command execution error", e)
|
logger.warn("Command execution error", e)
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract suspend fun internalExecute(command: T, executor: CommandExecutor): R
|
protected abstract suspend fun internalExecute(command: T, executor: CommandExecutor): R
|
||||||
|
|
|
@ -87,7 +87,6 @@ class SecurityConfig {
|
||||||
authorize(anyRequest, authenticated)
|
authorize(anyRequest, authenticated)
|
||||||
}
|
}
|
||||||
formLogin {
|
formLogin {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return http.build()
|
return http.build()
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.domain.model.actor
|
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)
|
||||||
|
|
|
@ -59,7 +59,6 @@ class Post(
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun setVisibility(visibility: Visibility, actor: Actor) {
|
fun setVisibility(visibility: Visibility, actor: Actor) {
|
||||||
|
|
||||||
require(isAllow(actor, UPDATE, this))
|
require(isAllow(actor, UPDATE, this))
|
||||||
require(this.visibility != Visibility.DIRECT)
|
require(this.visibility != Visibility.DIRECT)
|
||||||
require(visibility != Visibility.DIRECT)
|
require(visibility != Visibility.DIRECT)
|
||||||
|
@ -77,7 +76,6 @@ class Post(
|
||||||
private set
|
private set
|
||||||
|
|
||||||
fun setVisibleActors(visibleActors: Set<ActorId>, actor: Actor) {
|
fun setVisibleActors(visibleActors: Set<ActorId>, actor: Actor) {
|
||||||
|
|
||||||
require(isAllow(actor, UPDATE, this))
|
require(isAllow(actor, UPDATE, this))
|
||||||
require(deleted.not())
|
require(deleted.not())
|
||||||
if (visibility == Visibility.DIRECT) {
|
if (visibility == Visibility.DIRECT) {
|
||||||
|
@ -266,7 +264,6 @@ class Post(
|
||||||
moveTo: PostId? = null,
|
moveTo: PostId? = null,
|
||||||
actor: Actor,
|
actor: Actor,
|
||||||
): Post {
|
): Post {
|
||||||
|
|
||||||
require(actor.deleted.not())
|
require(actor.deleted.not())
|
||||||
require(actor.moveTo == null)
|
require(actor.moveTo == null)
|
||||||
|
|
||||||
|
@ -310,10 +307,10 @@ class Post(
|
||||||
}
|
}
|
||||||
|
|
||||||
MOVE -> resource.actorId == actor.id && actor.deleted.not()
|
MOVE -> resource.actorId == actor.id && actor.deleted.not()
|
||||||
DELETE -> resource.actorId == actor.id ||
|
DELETE ->
|
||||||
|
resource.actorId == actor.id ||
|
||||||
actor.roles.contains(Role.ADMINISTRATOR) ||
|
actor.roles.contains(Role.ADMINISTRATOR) ||
|
||||||
actor.roles.contains(Role.MODERATOR)
|
actor.roles.contains(Role.MODERATOR)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,5 +25,4 @@ data class PostContent(val text: String, val content: String, val emojiIds: List
|
||||||
val contentLength = 5000
|
val contentLength = 5000
|
||||||
val textLength = 3000
|
val textLength = 3000
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,6 @@ class Relationship(
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun default(actorId: ActorId, targetActorId: ActorId): Relationship = Relationship(
|
fun default(actorId: ActorId, targetActorId: ActorId): Relationship = Relationship(
|
||||||
actorId = actorId,
|
actorId = actorId,
|
||||||
|
|
|
@ -61,9 +61,7 @@ class FilterDomainService : IFilterDomainService {
|
||||||
|
|
||||||
post to filterResults
|
post to filterResults
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
.map { FilteredPost(it.first, it.second) }
|
.map { FilteredPost(it.first, it.second) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.domain.service.post
|
package dev.usbharu.hideout.core.domain.service.post
|
||||||
|
|
||||||
|
|
||||||
interface PostContentFormatter {
|
interface PostContentFormatter {
|
||||||
fun format(content: String): FormattedPostContent
|
fun format(content: String): FormattedPostContent
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,6 @@ class PostQueryMapper(private val postResultRowMapper: ResultRowMapper<Post>) :
|
||||||
?.let { actorId -> ActorId(actorId) }
|
?.let { actorId -> ActorId(actorId) }
|
||||||
}.toSet()
|
}.toSet()
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,10 @@ import org.slf4j.Logger
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
class ExposedActorInstanceRelationshipRepository(override val domainEventPublisher: DomainEventPublisher) :
|
class ExposedActorInstanceRelationshipRepository(override val domainEventPublisher: DomainEventPublisher) :
|
||||||
ActorInstanceRelationshipRepository, AbstractRepository(),
|
ActorInstanceRelationshipRepository,
|
||||||
|
AbstractRepository(),
|
||||||
DomainEventPublishableRepository<ActorInstanceRelationship> {
|
DomainEventPublishableRepository<ActorInstanceRelationship> {
|
||||||
override suspend fun save(actorInstanceRelationship: ActorInstanceRelationship): ActorInstanceRelationship {
|
override suspend fun save(actorInstanceRelationship: ActorInstanceRelationship): ActorInstanceRelationship {
|
||||||
query {
|
query {
|
||||||
|
|
|
@ -43,13 +43,11 @@ class ExposedApplicationRepository : ApplicationRepository, AbstractRepository()
|
||||||
override val logger: Logger
|
override val logger: Logger
|
||||||
get() = Companion.logger
|
get() = Companion.logger
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val logger = LoggerFactory.getLogger(ExposedApplicationRepository::class.java)
|
private val logger = LoggerFactory.getLogger(ExposedApplicationRepository::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
object Applications : Table("applications") {
|
object Applications : Table("applications") {
|
||||||
val id = long("id")
|
val id = long("id")
|
||||||
val name = varchar("name", 500)
|
val name = varchar("name", 500)
|
||||||
|
|
|
@ -28,7 +28,8 @@ import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
class ExposedRelationshipRepository(override val domainEventPublisher: DomainEventPublisher) : RelationshipRepository,
|
class ExposedRelationshipRepository(override val domainEventPublisher: DomainEventPublisher) :
|
||||||
|
RelationshipRepository,
|
||||||
AbstractRepository(),
|
AbstractRepository(),
|
||||||
DomainEventPublishableRepository<Relationship> {
|
DomainEventPublishableRepository<Relationship> {
|
||||||
override suspend fun save(relationship: Relationship): Relationship {
|
override suspend fun save(relationship: Relationship): Relationship {
|
||||||
|
@ -65,7 +66,6 @@ class ExposedRelationshipRepository(override val domainEventPublisher: DomainEve
|
||||||
override val logger: Logger
|
override val logger: Logger
|
||||||
get() = Companion.logger
|
get() = Companion.logger
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val logger = LoggerFactory.getLogger(ExposedRelationshipRepository::class.java)
|
private val logger = LoggerFactory.getLogger(ExposedRelationshipRepository::class.java)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.springframework.stereotype.Component
|
||||||
import org.springframework.web.context.request.RequestContextHolder
|
import org.springframework.web.context.request.RequestContextHolder
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes
|
import org.springframework.web.context.request.ServletRequestAttributes
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
class SpringMvcCommandExecutorFactory {
|
class SpringMvcCommandExecutorFactory {
|
||||||
fun getCommandExecutor(): HttpCommandExecutor {
|
fun getCommandExecutor(): HttpCommandExecutor {
|
||||||
|
|
|
@ -20,7 +20,9 @@ import dev.usbharu.hideout.core.domain.service.userdetail.PasswordEncoder
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
class SpringSecurityPasswordEncoder(private val passwordEncoder: org.springframework.security.crypto.password.PasswordEncoder) :
|
class SpringSecurityPasswordEncoder(
|
||||||
|
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 {
|
||||||
return passwordEncoder.encode(input)
|
return passwordEncoder.encode(input)
|
||||||
|
|
|
@ -31,10 +31,10 @@ class HideoutJdbcOauth2AuthorizationService(
|
||||||
@Autowired(required = false) lobHandler: LobHandler = DefaultLobHandler(),
|
@Autowired(required = false) lobHandler: LobHandler = DefaultLobHandler(),
|
||||||
) : JdbcOAuth2AuthorizationService(jdbcOperations, registeredClientRepository, lobHandler) {
|
) : JdbcOAuth2AuthorizationService(jdbcOperations, registeredClientRepository, lobHandler) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
super.setAuthorizationRowMapper(HideoutOAuth2AuthorizationRowMapper(registeredClientRepository = registeredClientRepository))
|
super.setAuthorizationRowMapper(
|
||||||
|
HideoutOAuth2AuthorizationRowMapper(registeredClientRepository = registeredClientRepository)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
class HideoutOAuth2AuthorizationRowMapper(registeredClientRepository: RegisteredClientRepository?) :
|
class HideoutOAuth2AuthorizationRowMapper(registeredClientRepository: RegisteredClientRepository?) :
|
||||||
|
|
|
@ -19,5 +19,6 @@ package dev.usbharu.hideout.core.infrastructure.springframework.oauth2
|
||||||
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
import dev.usbharu.hideout.core.application.shared.CommandExecutor
|
||||||
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
import dev.usbharu.hideout.core.application.shared.UserDetailGettableCommandExecutor
|
||||||
|
|
||||||
class Oauth2CommandExecutor(override val executor: String, override val userDetailId: Long) : CommandExecutor,
|
class Oauth2CommandExecutor(override val executor: String, override val userDetailId: Long) :
|
||||||
|
CommandExecutor,
|
||||||
UserDetailGettableCommandExecutor
|
UserDetailGettableCommandExecutor
|
|
@ -29,6 +29,5 @@ class Oauth2CommandExecutorFactory {
|
||||||
principal.subject,
|
principal.subject,
|
||||||
principal.getClaim<String>("uid").toLong()
|
principal.getClaim<String>("uid").toLong()
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -49,6 +49,5 @@ class UserDetailsServiceImpl(
|
||||||
userDetailsId = userDetail.id.id
|
userDetailsId = userDetail.id.id
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -43,8 +43,6 @@ class JsonOrFormModelMethodProcessor(
|
||||||
webRequest: NativeWebRequest,
|
webRequest: NativeWebRequest,
|
||||||
binderFactory: WebDataBinderFactory?,
|
binderFactory: WebDataBinderFactory?,
|
||||||
): Any? {
|
): Any? {
|
||||||
|
|
||||||
|
|
||||||
val contentType = webRequest.getHeader("Content-Type").orEmpty()
|
val contentType = webRequest.getHeader("Content-Type").orEmpty()
|
||||||
logger.trace("ContentType is {}", contentType)
|
logger.trace("ContentType is {}", contentType)
|
||||||
if (contentType.contains(isJsonRegex)) {
|
if (contentType.contains(isJsonRegex)) {
|
||||||
|
|
|
@ -44,5 +44,4 @@ object RsaUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun decodeRsaPrivateKey(encoded: String): RSAPrivateKey = decodeRsaPrivateKey(Base64Util.decode(encoded))
|
fun decodeRsaPrivateKey(encoded: String): RSAPrivateKey = decodeRsaPrivateKey(Base64Util.decode(encoded))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ plugins {
|
||||||
rootProject.name = "hideout"
|
rootProject.name = "hideout"
|
||||||
|
|
||||||
includeBuild("hideout-core")
|
includeBuild("hideout-core")
|
||||||
includeBuild("hideout-worker")
|
|
||||||
includeBuild("hideout-mastodon")
|
includeBuild("hideout-mastodon")
|
||||||
|
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
|
|
Loading…
Reference in New Issue