mirror of
https://github.com/usbharu/Hideout.git
synced 2026-09-29 00:11:27 +00:00
style: fix lint (CI)
This commit is contained in:
committed by
github-actions[bot]
parent
d5f08ef710
commit
6d997e8012
+9
-7
@@ -58,13 +58,15 @@ class MigrationLocalActorApplicationService(
|
||||
if (canAccountMigration.canMigration) {
|
||||
fromActor.moveTo = toActorId
|
||||
actorRepository.save(fromActor)
|
||||
} else when (canAccountMigration) {
|
||||
is AlreadyMoved -> throw IllegalArgumentException(canAccountMigration.message)
|
||||
is CanAccountMigration -> throw InternalServerException()
|
||||
is CircularReferences -> throw IllegalArgumentException(canAccountMigration.message)
|
||||
is SelfReferences -> throw IllegalArgumentException("Self references are not supported")
|
||||
is AlsoKnownAsNotFound -> throw IllegalArgumentException(canAccountMigration.message)
|
||||
is MigrationCoolDown -> throw IllegalArgumentException(canAccountMigration.message)
|
||||
} else {
|
||||
when (canAccountMigration) {
|
||||
is AlreadyMoved -> throw IllegalArgumentException(canAccountMigration.message)
|
||||
is CanAccountMigration -> throw InternalServerException()
|
||||
is CircularReferences -> throw IllegalArgumentException(canAccountMigration.message)
|
||||
is SelfReferences -> throw IllegalArgumentException("Self references are not supported")
|
||||
is AlsoKnownAsNotFound -> throw IllegalArgumentException(canAccountMigration.message)
|
||||
is MigrationCoolDown -> throw IllegalArgumentException(canAccountMigration.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -91,7 +91,6 @@ class RegisterApplicationApplicationService(
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(RegisterApplicationApplicationService::class.java)
|
||||
}
|
||||
|
||||
+3
-5
@@ -36,15 +36,13 @@ class TimelineRelationshipFollowSubscriber(
|
||||
relationship.targetActorId,
|
||||
Visible.FOLLOWERS
|
||||
)
|
||||
), it.body.principal
|
||||
),
|
||||
it.body.principal
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(TimelineRelationshipFollowSubscriber::class.java)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,4 +11,4 @@ class InternalServerException : RuntimeException {
|
||||
enableSuppression,
|
||||
writableStackTrace
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,4 +11,4 @@ class PermissionDeniedException : RuntimeException {
|
||||
enableSuppression,
|
||||
writableStackTrace
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -37,7 +37,6 @@ class UserRegisterFilterApplicationService(
|
||||
) {
|
||||
|
||||
override suspend fun internalExecute(command: RegisterFilter, principal: LocalUser): Filter {
|
||||
|
||||
val filter = dev.usbharu.hideout.core.domain.model.filter.Filter.create(
|
||||
id = FilterId(idGenerateService.generateId()),
|
||||
userDetailId = principal.userDetailId,
|
||||
|
||||
+7
-5
@@ -16,18 +16,20 @@ class GetLocalInstanceApplicationService(
|
||||
transaction: Transaction
|
||||
) :
|
||||
AbstractApplicationService<Unit, Instance>(
|
||||
transaction, logger
|
||||
transaction,
|
||||
logger
|
||||
) {
|
||||
var cachedInstance: Instance? = null
|
||||
|
||||
override suspend fun internalExecute(command: Unit, principal: Principal): Instance {
|
||||
|
||||
if (cachedInstance != null) {
|
||||
return cachedInstance!!
|
||||
}
|
||||
|
||||
val instance = (instanceRepository.findByUrl(applicationConfig.url.toURI())
|
||||
?: throw InternalServerException("Local instance not found."))
|
||||
val instance = (
|
||||
instanceRepository.findByUrl(applicationConfig.url.toURI())
|
||||
?: throw InternalServerException("Local instance not found.")
|
||||
)
|
||||
|
||||
cachedInstance = Instance.of(instance)
|
||||
return cachedInstance!!
|
||||
@@ -36,4 +38,4 @@ class GetLocalInstanceApplicationService(
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(GetLocalInstanceApplicationService::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -7,7 +7,10 @@ data class Instance(val id: Long, val name: String, val url: URI, val descriptio
|
||||
companion object {
|
||||
fun of(instance: Instance): dev.usbharu.hideout.core.application.instance.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
-2
@@ -1,6 +1,5 @@
|
||||
package dev.usbharu.hideout.core.application.post
|
||||
|
||||
|
||||
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.media.Media
|
||||
@@ -32,4 +31,4 @@ data class ActorDetail(
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -29,7 +29,8 @@ import org.springframework.stereotype.Service
|
||||
@Service
|
||||
class DeleteLocalPostApplicationService(
|
||||
private val postRepository: PostRepository,
|
||||
private val actorRepository: ActorRepository, transaction: Transaction,
|
||||
private val actorRepository: ActorRepository,
|
||||
transaction: Transaction,
|
||||
) : LocalUserAbstractApplicationService<DeleteLocalPost, Unit>(transaction, logger) {
|
||||
|
||||
override suspend fun internalExecute(command: DeleteLocalPost, principal: LocalUser) {
|
||||
|
||||
+8
-4
@@ -25,7 +25,8 @@ class GetPostDetailApplicationService(
|
||||
private val mediaRepository: MediaRepository,
|
||||
private val iPostReadAccessControl: IPostReadAccessControl
|
||||
) : AbstractApplicationService<GetPostDetail, PostDetail>(
|
||||
transaction, logger
|
||||
transaction,
|
||||
logger
|
||||
) {
|
||||
override suspend fun internalExecute(command: GetPostDetail, principal: Principal): PostDetail {
|
||||
val post = postRepository.findById(PostId(command.postId))
|
||||
@@ -79,12 +80,15 @@ class GetPostDetailApplicationService(
|
||||
|
||||
val mediaList = mediaRepository.findByIds(post.mediaIds)
|
||||
return PostDetail.of(
|
||||
post, first, second, third, mediaList
|
||||
post,
|
||||
first,
|
||||
second,
|
||||
third,
|
||||
mediaList
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(GetPostDetailApplicationService::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,4 +25,4 @@ data class MediaDetail(
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -35,7 +35,6 @@ class UserAcceptFollowRequestApplicationService(
|
||||
) :
|
||||
LocalUserAbstractApplicationService<AcceptFollowRequest, Unit>(transaction, logger) {
|
||||
override suspend fun internalExecute(command: AcceptFollowRequest, principal: LocalUser) {
|
||||
|
||||
val actor = actorRepository.findById(principal.actorId)
|
||||
?: throw InternalServerException("Actor ${principal.actorId} not found")
|
||||
|
||||
|
||||
-2
@@ -36,8 +36,6 @@ class UserBlockApplicationService(
|
||||
) :
|
||||
LocalUserAbstractApplicationService<Block, Unit>(transaction, logger) {
|
||||
override suspend fun internalExecute(command: Block, principal: LocalUser) {
|
||||
|
||||
|
||||
val actor = actorRepository.findById(principal.actorId)
|
||||
?: throw IllegalStateException("Actor ${principal.actorId} not found")
|
||||
|
||||
|
||||
+6
-6
@@ -46,14 +46,14 @@ class GetRelationshipApplicationService(
|
||||
val target = actorRepository.findById(targetId)
|
||||
?: throw IllegalArgumentException("Actor ${command.targetActorId} not found.")
|
||||
val relationship = (
|
||||
relationshipRepository.findByActorIdAndTargetId(actor.id, targetId)
|
||||
?: 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)
|
||||
?: 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 =
|
||||
actorInstanceRelationshipRepository.findByActorIdAndInstanceId(actor.id, target.instance)
|
||||
|
||||
+1
-1
@@ -15,4 +15,4 @@ abstract class LocalUserAbstractApplicationService<T : Any, R>(transaction: Tran
|
||||
}
|
||||
|
||||
protected abstract suspend fun internalExecute(command: T, principal: LocalUser): R
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -13,7 +13,8 @@ class UserAddTimelineRelationshipApplicationService(
|
||||
transaction: Transaction
|
||||
) :
|
||||
LocalUserAbstractApplicationService<AddTimelineRelationship, Unit>(
|
||||
transaction, logger
|
||||
transaction,
|
||||
logger
|
||||
) {
|
||||
override suspend fun internalExecute(command: AddTimelineRelationship, principal: LocalUser) {
|
||||
timelineRelationshipRepository.save(command.timelineRelationship)
|
||||
@@ -22,4 +23,4 @@ class UserAddTimelineRelationshipApplicationService(
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(UserAddTimelineRelationshipApplicationService::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,4 @@ data class ApplicationConfig(
|
||||
val url: URL,
|
||||
val private: Boolean = true,
|
||||
val keySize: Int = 2048,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -69,7 +69,6 @@ class Filter(
|
||||
return id.hashCode()
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
fun isAllow(user: UserDetail, action: Action, resource: Filter): Boolean {
|
||||
return when (action) {
|
||||
|
||||
@@ -241,25 +241,25 @@ class Post(
|
||||
|
||||
override fun toString(): String {
|
||||
return "Post(" +
|
||||
"id=$id, " +
|
||||
"createdAt=$createdAt, " +
|
||||
"url=$url, " +
|
||||
"repostId=$repostId, " +
|
||||
"replyId=$replyId, " +
|
||||
"apId=$apId, " +
|
||||
"actorId=$actorId, " +
|
||||
"visibility=$visibility, " +
|
||||
"visibleActors=$visibleActors, " +
|
||||
"content=$content, " +
|
||||
"overview=$overview, " +
|
||||
"sensitive=$sensitive, " +
|
||||
"text='$text', " +
|
||||
"emojiIds=$emojiIds, " +
|
||||
"mediaIds=$mediaIds, " +
|
||||
"deleted=$deleted, " +
|
||||
"hide=$hide, " +
|
||||
"moveTo=$moveTo" +
|
||||
")"
|
||||
"id=$id, " +
|
||||
"createdAt=$createdAt, " +
|
||||
"url=$url, " +
|
||||
"repostId=$repostId, " +
|
||||
"replyId=$replyId, " +
|
||||
"apId=$apId, " +
|
||||
"actorId=$actorId, " +
|
||||
"visibility=$visibility, " +
|
||||
"visibleActors=$visibleActors, " +
|
||||
"content=$content, " +
|
||||
"overview=$overview, " +
|
||||
"sensitive=$sensitive, " +
|
||||
"text='$text', " +
|
||||
"emojiIds=$emojiIds, " +
|
||||
"mediaIds=$mediaIds, " +
|
||||
"deleted=$deleted, " +
|
||||
"hide=$hide, " +
|
||||
"moveTo=$moveTo" +
|
||||
")"
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -315,6 +315,5 @@ class Post(
|
||||
post.addDomainEvent(PostDomainEventFactory(post).createEvent(PostEvent.CREATE))
|
||||
return post
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@ package dev.usbharu.hideout.core.domain.model.support.principal
|
||||
|
||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||
|
||||
data object Anonymous : Principal(ActorId.ghost, null, null)
|
||||
data object Anonymous : Principal(ActorId.ghost, null, null)
|
||||
|
||||
+1
-1
@@ -12,4 +12,4 @@ class LocalUser(
|
||||
actorId,
|
||||
userDetailId,
|
||||
acct
|
||||
)
|
||||
)
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@ import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||
import dev.usbharu.hideout.core.domain.model.support.acct.Acct
|
||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||
|
||||
sealed class Principal(open val actorId: ActorId, open val userDetailId: UserDetailId?, open val acct: Acct?)
|
||||
sealed class Principal(open val actorId: ActorId, open val userDetailId: UserDetailId?, open val acct: Acct?)
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@ package dev.usbharu.hideout.core.domain.model.support.principal
|
||||
|
||||
interface PrincipalContextHolder {
|
||||
suspend fun getPrincipal(): Principal
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -33,7 +33,7 @@ class TimelineObject(
|
||||
lastUpdatedAt: Instant,
|
||||
var warnFilters: List<TimelineObjectWarnFilter>,
|
||||
|
||||
) {
|
||||
) {
|
||||
var isPureRepost = isPureRepost
|
||||
private set
|
||||
var visibleActors = visibleActors
|
||||
@@ -125,9 +125,9 @@ class TimelineObject(
|
||||
repostActorId = repost.actorId,
|
||||
visibility = post.visibility,
|
||||
isPureRepost = repost.mediaIds.isEmpty() &&
|
||||
repost.overview == null &&
|
||||
repost.content == PostContent.empty &&
|
||||
repost.replyId == null,
|
||||
repost.overview == null &&
|
||||
repost.content == PostContent.empty &&
|
||||
repost.replyId == null,
|
||||
mediaIds = post.mediaIds,
|
||||
emojiIds = post.emojiIds,
|
||||
visibleActors = post.visibleActors.toList(),
|
||||
|
||||
+12
-12
@@ -16,36 +16,37 @@ interface IPostReadAccessControl {
|
||||
class DefaultPostReadAccessControl(private val relationshipRepository: RelationshipRepository) :
|
||||
IPostReadAccessControl {
|
||||
override suspend fun isAllow(post: Post, principal: Principal): Boolean {
|
||||
|
||||
//ポスト主は無条件で見れる
|
||||
// ポスト主は無条件で見れる
|
||||
if (post.actorId == principal.actorId) {
|
||||
return true
|
||||
}
|
||||
|
||||
val relationship = (relationshipRepository.findByActorIdAndTargetId(post.actorId, principal.actorId)
|
||||
?: Relationship.default(post.actorId, principal.actorId))
|
||||
val relationship = (
|
||||
relationshipRepository.findByActorIdAndTargetId(post.actorId, principal.actorId)
|
||||
?: Relationship.default(post.actorId, principal.actorId)
|
||||
)
|
||||
|
||||
//ブロックされてたら見れない
|
||||
// ブロックされてたら見れない
|
||||
if (relationship.blocking) {
|
||||
return false
|
||||
}
|
||||
|
||||
//PublicかUnlistedなら見れる
|
||||
// PublicかUnlistedなら見れる
|
||||
if (post.visibility == Visibility.PUBLIC || post.visibility == Visibility.UNLISTED) {
|
||||
return true
|
||||
}
|
||||
|
||||
//principalがAnonymousなら見れない
|
||||
// principalがAnonymousなら見れない
|
||||
if (principal is Anonymous) {
|
||||
return false
|
||||
}
|
||||
|
||||
//DirectでvisibleActorsに含まれていたら見れる
|
||||
// DirectでvisibleActorsに含まれていたら見れる
|
||||
if (post.visibility == Visibility.DIRECT && post.visibleActors.contains(principal.actorId)) {
|
||||
return true
|
||||
}
|
||||
|
||||
//Followersでフォロワーなら見れる
|
||||
// Followersでフォロワーなら見れる
|
||||
if (post.visibility == Visibility.FOLLOWERS) {
|
||||
val inverseRelationship =
|
||||
relationshipRepository.findByActorIdAndTargetId(principal.actorId, post.actorId) ?: return false
|
||||
@@ -53,8 +54,7 @@ class DefaultPostReadAccessControl(private val relationshipRepository: Relations
|
||||
return inverseRelationship.following
|
||||
}
|
||||
|
||||
//その他の場合は見れない
|
||||
// その他の場合は見れない
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,4 +34,4 @@ class ExposedPrincipalQueryService : PrincipalQueryService, AbstractRepository()
|
||||
companion object {
|
||||
private val logger: Logger = LoggerFactory.getLogger(ExposedPrincipalQueryService::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -22,7 +22,6 @@ class SpringSecurityFormLoginPrincipalContextHolder(
|
||||
SecurityContextHolder.getContext().authentication?.principal as? HideoutUserDetails ?: return Anonymous
|
||||
|
||||
return transaction.transaction {
|
||||
|
||||
val userDetail = principalQueryService.findByUserDetailId(UserDetailId(hideoutUserDetails.userDetailsId))
|
||||
LocalUser(
|
||||
userDetail.actorId,
|
||||
@@ -30,6 +29,5 @@ class SpringSecurityFormLoginPrincipalContextHolder(
|
||||
Acct(userDetail.username, userDetail.host)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,4 +33,4 @@ class SpringSecurityOauth2PrincipalContextHolder(
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,4 +30,4 @@ data class InternalTimelineObjectOption(
|
||||
val localOnly: Boolean? = null,
|
||||
val remoteOnly: Boolean? = null,
|
||||
val mediaOnly: Boolean? = null
|
||||
)
|
||||
)
|
||||
|
||||
+2
-1
@@ -38,7 +38,8 @@ class AuthController(
|
||||
suspend fun signUp(@Validated @ModelAttribute signUpForm: SignUpForm, request: HttpServletRequest): String {
|
||||
val registerLocalActor = RegisterLocalActor(signUpForm.username, signUpForm.password)
|
||||
val uri = registerLocalActorApplicationService.execute(
|
||||
registerLocalActor, Anonymous
|
||||
registerLocalActor,
|
||||
Anonymous
|
||||
)
|
||||
request.login(signUpForm.username, signUpForm.password)
|
||||
return "redirect:$uri"
|
||||
|
||||
+1
-2
@@ -30,7 +30,6 @@ import org.springframework.web.bind.annotation.PathVariable
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.name
|
||||
|
||||
|
||||
@Controller
|
||||
@ConditionalOnProperty("hideout.storage.type", havingValue = "local", matchIfMissing = true)
|
||||
class LocalFileController(
|
||||
@@ -64,4 +63,4 @@ class LocalFileController(
|
||||
.contentLength(pathResource.contentLength())
|
||||
.body(pathResource)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,4 +31,4 @@ class PostsController(
|
||||
|
||||
return "postById"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -55,6 +55,6 @@ class PublishController(
|
||||
)
|
||||
val id = userRegisterLocalPostApplicationService.execute(command, principal)
|
||||
|
||||
return "redirect:/users/${principal.acct?.userpart}/posts/${id}"
|
||||
return "redirect:/users/${principal.acct?.userpart}/posts/$id"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,4 +3,4 @@ package dev.usbharu.hideout.core.query.principal
|
||||
import dev.usbharu.hideout.core.domain.model.actor.ActorId
|
||||
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||
|
||||
data class PrincipalDTO(val userDetailId: UserDetailId, val actorId: ActorId, val username: String, val host: String)
|
||||
data class PrincipalDTO(val userDetailId: UserDetailId, val actorId: ActorId, val username: String, val host: String)
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@ import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
|
||||
|
||||
interface PrincipalQueryService {
|
||||
suspend fun findByUserDetailId(userDetailId: UserDetailId): PrincipalDTO
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user