mirror of https://github.com/usbharu/Hideout.git
style: fix lint (CI)
This commit is contained in:
parent
d5f08ef710
commit
6d997e8012
|
@ -58,7 +58,8 @@ class MigrationLocalActorApplicationService(
|
||||||
if (canAccountMigration.canMigration) {
|
if (canAccountMigration.canMigration) {
|
||||||
fromActor.moveTo = toActorId
|
fromActor.moveTo = toActorId
|
||||||
actorRepository.save(fromActor)
|
actorRepository.save(fromActor)
|
||||||
} else when (canAccountMigration) {
|
} else {
|
||||||
|
when (canAccountMigration) {
|
||||||
is AlreadyMoved -> throw IllegalArgumentException(canAccountMigration.message)
|
is AlreadyMoved -> throw IllegalArgumentException(canAccountMigration.message)
|
||||||
is CanAccountMigration -> throw InternalServerException()
|
is CanAccountMigration -> throw InternalServerException()
|
||||||
is CircularReferences -> throw IllegalArgumentException(canAccountMigration.message)
|
is CircularReferences -> throw IllegalArgumentException(canAccountMigration.message)
|
||||||
|
@ -67,6 +68,7 @@ class MigrationLocalActorApplicationService(
|
||||||
is MigrationCoolDown -> throw IllegalArgumentException(canAccountMigration.message)
|
is MigrationCoolDown -> throw IllegalArgumentException(canAccountMigration.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val logger = LoggerFactory.getLogger(MigrationLocalActorApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(MigrationLocalActorApplicationService::class.java)
|
||||||
|
|
|
@ -91,7 +91,6 @@ class RegisterApplicationApplicationService(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val logger = LoggerFactory.getLogger(RegisterApplicationApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(RegisterApplicationApplicationService::class.java)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,15 +36,13 @@ class TimelineRelationshipFollowSubscriber(
|
||||||
relationship.targetActorId,
|
relationship.targetActorId,
|
||||||
Visible.FOLLOWERS
|
Visible.FOLLOWERS
|
||||||
)
|
)
|
||||||
), it.body.principal
|
),
|
||||||
|
it.body.principal
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val logger = LoggerFactory.getLogger(TimelineRelationshipFollowSubscriber::class.java)
|
private val logger = LoggerFactory.getLogger(TimelineRelationshipFollowSubscriber::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -37,7 +37,6 @@ class UserRegisterFilterApplicationService(
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override suspend fun internalExecute(command: RegisterFilter, principal: LocalUser): Filter {
|
override suspend fun internalExecute(command: RegisterFilter, principal: LocalUser): Filter {
|
||||||
|
|
||||||
val filter = dev.usbharu.hideout.core.domain.model.filter.Filter.create(
|
val filter = dev.usbharu.hideout.core.domain.model.filter.Filter.create(
|
||||||
id = FilterId(idGenerateService.generateId()),
|
id = FilterId(idGenerateService.generateId()),
|
||||||
userDetailId = principal.userDetailId,
|
userDetailId = principal.userDetailId,
|
||||||
|
|
|
@ -16,18 +16,20 @@ class GetLocalInstanceApplicationService(
|
||||||
transaction: Transaction
|
transaction: Transaction
|
||||||
) :
|
) :
|
||||||
AbstractApplicationService<Unit, Instance>(
|
AbstractApplicationService<Unit, Instance>(
|
||||||
transaction, logger
|
transaction,
|
||||||
|
logger
|
||||||
) {
|
) {
|
||||||
var cachedInstance: Instance? = null
|
var cachedInstance: Instance? = null
|
||||||
|
|
||||||
override suspend fun internalExecute(command: Unit, principal: Principal): Instance {
|
override suspend fun internalExecute(command: Unit, principal: Principal): Instance {
|
||||||
|
|
||||||
if (cachedInstance != null) {
|
if (cachedInstance != null) {
|
||||||
return cachedInstance!!
|
return cachedInstance!!
|
||||||
}
|
}
|
||||||
|
|
||||||
val instance = (instanceRepository.findByUrl(applicationConfig.url.toURI())
|
val instance = (
|
||||||
?: throw InternalServerException("Local instance not found."))
|
instanceRepository.findByUrl(applicationConfig.url.toURI())
|
||||||
|
?: throw InternalServerException("Local instance not found.")
|
||||||
|
)
|
||||||
|
|
||||||
cachedInstance = Instance.of(instance)
|
cachedInstance = Instance.of(instance)
|
||||||
return cachedInstance!!
|
return cachedInstance!!
|
||||||
|
|
|
@ -7,7 +7,10 @@ data class Instance(val id: Long, val name: String, val url: URI, val descriptio
|
||||||
companion object {
|
companion object {
|
||||||
fun of(instance: Instance): dev.usbharu.hideout.core.application.instance.Instance {
|
fun of(instance: Instance): dev.usbharu.hideout.core.application.instance.Instance {
|
||||||
return Instance(
|
return Instance(
|
||||||
instance.id.instanceId, instance.name.name, instance.url, instance.description.description
|
instance.id.instanceId,
|
||||||
|
instance.name.name,
|
||||||
|
instance.url,
|
||||||
|
instance.description.description
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package dev.usbharu.hideout.core.application.post
|
package dev.usbharu.hideout.core.application.post
|
||||||
|
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
import dev.usbharu.hideout.core.domain.model.actor.Actor
|
||||||
import dev.usbharu.hideout.core.domain.model.instance.Instance
|
import dev.usbharu.hideout.core.domain.model.instance.Instance
|
||||||
import dev.usbharu.hideout.core.domain.model.media.Media
|
import dev.usbharu.hideout.core.domain.model.media.Media
|
||||||
|
|
|
@ -29,7 +29,8 @@ import org.springframework.stereotype.Service
|
||||||
@Service
|
@Service
|
||||||
class DeleteLocalPostApplicationService(
|
class DeleteLocalPostApplicationService(
|
||||||
private val postRepository: PostRepository,
|
private val postRepository: PostRepository,
|
||||||
private val actorRepository: ActorRepository, transaction: Transaction,
|
private val actorRepository: ActorRepository,
|
||||||
|
transaction: Transaction,
|
||||||
) : LocalUserAbstractApplicationService<DeleteLocalPost, Unit>(transaction, logger) {
|
) : LocalUserAbstractApplicationService<DeleteLocalPost, Unit>(transaction, logger) {
|
||||||
|
|
||||||
override suspend fun internalExecute(command: DeleteLocalPost, principal: LocalUser) {
|
override suspend fun internalExecute(command: DeleteLocalPost, principal: LocalUser) {
|
||||||
|
|
|
@ -25,7 +25,8 @@ class GetPostDetailApplicationService(
|
||||||
private val mediaRepository: MediaRepository,
|
private val mediaRepository: MediaRepository,
|
||||||
private val iPostReadAccessControl: IPostReadAccessControl
|
private val iPostReadAccessControl: IPostReadAccessControl
|
||||||
) : AbstractApplicationService<GetPostDetail, PostDetail>(
|
) : AbstractApplicationService<GetPostDetail, PostDetail>(
|
||||||
transaction, logger
|
transaction,
|
||||||
|
logger
|
||||||
) {
|
) {
|
||||||
override suspend fun internalExecute(command: GetPostDetail, principal: Principal): PostDetail {
|
override suspend fun internalExecute(command: GetPostDetail, principal: Principal): PostDetail {
|
||||||
val post = postRepository.findById(PostId(command.postId))
|
val post = postRepository.findById(PostId(command.postId))
|
||||||
|
@ -79,9 +80,12 @@ class GetPostDetailApplicationService(
|
||||||
|
|
||||||
val mediaList = mediaRepository.findByIds(post.mediaIds)
|
val mediaList = mediaRepository.findByIds(post.mediaIds)
|
||||||
return PostDetail.of(
|
return PostDetail.of(
|
||||||
post, first, second, third, mediaList
|
post,
|
||||||
|
first,
|
||||||
|
second,
|
||||||
|
third,
|
||||||
|
mediaList
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -35,7 +35,6 @@ class UserAcceptFollowRequestApplicationService(
|
||||||
) :
|
) :
|
||||||
LocalUserAbstractApplicationService<AcceptFollowRequest, Unit>(transaction, logger) {
|
LocalUserAbstractApplicationService<AcceptFollowRequest, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: AcceptFollowRequest, principal: LocalUser) {
|
override suspend fun internalExecute(command: AcceptFollowRequest, principal: LocalUser) {
|
||||||
|
|
||||||
val actor = actorRepository.findById(principal.actorId)
|
val actor = actorRepository.findById(principal.actorId)
|
||||||
?: throw InternalServerException("Actor ${principal.actorId} not found")
|
?: throw InternalServerException("Actor ${principal.actorId} not found")
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,6 @@ class UserBlockApplicationService(
|
||||||
) :
|
) :
|
||||||
LocalUserAbstractApplicationService<Block, Unit>(transaction, logger) {
|
LocalUserAbstractApplicationService<Block, Unit>(transaction, logger) {
|
||||||
override suspend fun internalExecute(command: Block, principal: LocalUser) {
|
override suspend fun internalExecute(command: Block, principal: LocalUser) {
|
||||||
|
|
||||||
|
|
||||||
val actor = actorRepository.findById(principal.actorId)
|
val actor = actorRepository.findById(principal.actorId)
|
||||||
?: throw IllegalStateException("Actor ${principal.actorId} not found")
|
?: throw IllegalStateException("Actor ${principal.actorId} not found")
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,8 @@ class UserAddTimelineRelationshipApplicationService(
|
||||||
transaction: Transaction
|
transaction: Transaction
|
||||||
) :
|
) :
|
||||||
LocalUserAbstractApplicationService<AddTimelineRelationship, Unit>(
|
LocalUserAbstractApplicationService<AddTimelineRelationship, Unit>(
|
||||||
transaction, logger
|
transaction,
|
||||||
|
logger
|
||||||
) {
|
) {
|
||||||
override suspend fun internalExecute(command: AddTimelineRelationship, principal: LocalUser) {
|
override suspend fun internalExecute(command: AddTimelineRelationship, principal: LocalUser) {
|
||||||
timelineRelationshipRepository.save(command.timelineRelationship)
|
timelineRelationshipRepository.save(command.timelineRelationship)
|
||||||
|
|
|
@ -69,7 +69,6 @@ class Filter(
|
||||||
return id.hashCode()
|
return id.hashCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun isAllow(user: UserDetail, action: Action, resource: Filter): Boolean {
|
fun isAllow(user: UserDetail, action: Action, resource: Filter): Boolean {
|
||||||
return when (action) {
|
return when (action) {
|
||||||
|
|
|
@ -315,6 +315,5 @@ class Post(
|
||||||
post.addDomainEvent(PostDomainEventFactory(post).createEvent(PostEvent.CREATE))
|
post.addDomainEvent(PostDomainEventFactory(post).createEvent(PostEvent.CREATE))
|
||||||
return post
|
return post
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ class TimelineObject(
|
||||||
lastUpdatedAt: Instant,
|
lastUpdatedAt: Instant,
|
||||||
var warnFilters: List<TimelineObjectWarnFilter>,
|
var warnFilters: List<TimelineObjectWarnFilter>,
|
||||||
|
|
||||||
) {
|
) {
|
||||||
var isPureRepost = isPureRepost
|
var isPureRepost = isPureRepost
|
||||||
private set
|
private set
|
||||||
var visibleActors = visibleActors
|
var visibleActors = visibleActors
|
||||||
|
|
|
@ -16,36 +16,37 @@ interface IPostReadAccessControl {
|
||||||
class DefaultPostReadAccessControl(private val relationshipRepository: RelationshipRepository) :
|
class DefaultPostReadAccessControl(private val relationshipRepository: RelationshipRepository) :
|
||||||
IPostReadAccessControl {
|
IPostReadAccessControl {
|
||||||
override suspend fun isAllow(post: Post, principal: Principal): Boolean {
|
override suspend fun isAllow(post: Post, principal: Principal): Boolean {
|
||||||
|
// ポスト主は無条件で見れる
|
||||||
//ポスト主は無条件で見れる
|
|
||||||
if (post.actorId == principal.actorId) {
|
if (post.actorId == principal.actorId) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
val relationship = (relationshipRepository.findByActorIdAndTargetId(post.actorId, principal.actorId)
|
val relationship = (
|
||||||
?: Relationship.default(post.actorId, principal.actorId))
|
relationshipRepository.findByActorIdAndTargetId(post.actorId, principal.actorId)
|
||||||
|
?: Relationship.default(post.actorId, principal.actorId)
|
||||||
|
)
|
||||||
|
|
||||||
//ブロックされてたら見れない
|
// ブロックされてたら見れない
|
||||||
if (relationship.blocking) {
|
if (relationship.blocking) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
//PublicかUnlistedなら見れる
|
// PublicかUnlistedなら見れる
|
||||||
if (post.visibility == Visibility.PUBLIC || post.visibility == Visibility.UNLISTED) {
|
if (post.visibility == Visibility.PUBLIC || post.visibility == Visibility.UNLISTED) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
//principalがAnonymousなら見れない
|
// principalがAnonymousなら見れない
|
||||||
if (principal is Anonymous) {
|
if (principal is Anonymous) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
//DirectでvisibleActorsに含まれていたら見れる
|
// DirectでvisibleActorsに含まれていたら見れる
|
||||||
if (post.visibility == Visibility.DIRECT && post.visibleActors.contains(principal.actorId)) {
|
if (post.visibility == Visibility.DIRECT && post.visibleActors.contains(principal.actorId)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
//Followersでフォロワーなら見れる
|
// Followersでフォロワーなら見れる
|
||||||
if (post.visibility == Visibility.FOLLOWERS) {
|
if (post.visibility == Visibility.FOLLOWERS) {
|
||||||
val inverseRelationship =
|
val inverseRelationship =
|
||||||
relationshipRepository.findByActorIdAndTargetId(principal.actorId, post.actorId) ?: return false
|
relationshipRepository.findByActorIdAndTargetId(principal.actorId, post.actorId) ?: return false
|
||||||
|
@ -53,8 +54,7 @@ class DefaultPostReadAccessControl(private val relationshipRepository: Relations
|
||||||
return inverseRelationship.following
|
return inverseRelationship.following
|
||||||
}
|
}
|
||||||
|
|
||||||
//その他の場合は見れない
|
// その他の場合は見れない
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -22,7 +22,6 @@ class SpringSecurityFormLoginPrincipalContextHolder(
|
||||||
SecurityContextHolder.getContext().authentication?.principal as? HideoutUserDetails ?: return Anonymous
|
SecurityContextHolder.getContext().authentication?.principal as? HideoutUserDetails ?: return Anonymous
|
||||||
|
|
||||||
return transaction.transaction {
|
return transaction.transaction {
|
||||||
|
|
||||||
val userDetail = principalQueryService.findByUserDetailId(UserDetailId(hideoutUserDetails.userDetailsId))
|
val userDetail = principalQueryService.findByUserDetailId(UserDetailId(hideoutUserDetails.userDetailsId))
|
||||||
LocalUser(
|
LocalUser(
|
||||||
userDetail.actorId,
|
userDetail.actorId,
|
||||||
|
@ -30,6 +29,5 @@ class SpringSecurityFormLoginPrincipalContextHolder(
|
||||||
Acct(userDetail.username, userDetail.host)
|
Acct(userDetail.username, userDetail.host)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -38,7 +38,8 @@ class AuthController(
|
||||||
suspend fun signUp(@Validated @ModelAttribute signUpForm: SignUpForm, request: HttpServletRequest): String {
|
suspend fun signUp(@Validated @ModelAttribute signUpForm: SignUpForm, request: HttpServletRequest): String {
|
||||||
val registerLocalActor = RegisterLocalActor(signUpForm.username, signUpForm.password)
|
val registerLocalActor = RegisterLocalActor(signUpForm.username, signUpForm.password)
|
||||||
val uri = registerLocalActorApplicationService.execute(
|
val uri = registerLocalActorApplicationService.execute(
|
||||||
registerLocalActor, Anonymous
|
registerLocalActor,
|
||||||
|
Anonymous
|
||||||
)
|
)
|
||||||
request.login(signUpForm.username, signUpForm.password)
|
request.login(signUpForm.username, signUpForm.password)
|
||||||
return "redirect:$uri"
|
return "redirect:$uri"
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.springframework.web.bind.annotation.PathVariable
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.io.path.name
|
import kotlin.io.path.name
|
||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@ConditionalOnProperty("hideout.storage.type", havingValue = "local", matchIfMissing = true)
|
@ConditionalOnProperty("hideout.storage.type", havingValue = "local", matchIfMissing = true)
|
||||||
class LocalFileController(
|
class LocalFileController(
|
||||||
|
|
|
@ -55,6 +55,6 @@ class PublishController(
|
||||||
)
|
)
|
||||||
val id = userRegisterLocalPostApplicationService.execute(command, principal)
|
val id = userRegisterLocalPostApplicationService.execute(command, principal)
|
||||||
|
|
||||||
return "redirect:/users/${principal.acct?.userpart}/posts/${id}"
|
return "redirect:/users/${principal.acct?.userpart}/posts/$id"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue