style: fix lint

This commit is contained in:
usbharu 2024-09-09 18:47:02 +09:00
parent 2b2d9046d8
commit 39ad5a3125
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
11 changed files with 36 additions and 39 deletions

View File

@ -16,12 +16,12 @@ data class Reactions(
fun of(reactionList: List<Reaction>, customEmoji: CustomEmoji?): Reactions {
val first = reactionList.first()
return Reactions(
first.id.value,
reactionList.size,
customEmoji?.name ?: first.unicodeEmoji.name,
customEmoji?.domain?.domain ?: first.unicodeEmoji.domain.domain,
customEmoji?.url,
reactionList.map { it.actorId.id }
postId = first.id.value,
count = reactionList.size,
name = customEmoji?.name ?: first.unicodeEmoji.name,
domain = customEmoji?.domain?.domain ?: first.unicodeEmoji.domain.domain,
url = customEmoji?.url,
actorIds = reactionList.map { it.actorId.id }
)
}
}

View File

@ -44,10 +44,10 @@ class ReadTimelineApplicationService(
val reply = if (it.replyPost != null) {
@Suppress("UnsafeCallOnNullableType")
PostDetail.of(
it.replyPost,
it.replyPostActor!!,
it.replyPostActorIconMedia,
it.replyPostMedias.orEmpty(),
post = it.replyPost,
actor = it.replyPostActor!!,
iconMedia = it.replyPostActorIconMedia,
mediaList = it.replyPostMedias.orEmpty(),
reactionsList = emptyList(),
favourited = false,
)

View File

@ -27,15 +27,14 @@ class Reaction(
return id == other.id
}
override fun hashCode(): Int {
return id.hashCode()
}
override fun hashCode(): Int = id.hashCode()
fun delete() {
addDomainEvent(ReactionEventFactory(this).createEvent(ReactionEvent.DELETE))
}
companion object {
@Suppress("LongParameterList")
fun create(
id: ReactionId,
postId: PostId,

View File

@ -4,6 +4,7 @@ import dev.usbharu.hideout.core.domain.model.actor.ActorId
import dev.usbharu.hideout.core.domain.model.emoji.CustomEmojiId
import dev.usbharu.hideout.core.domain.model.post.PostId
@Suppress("FunctionMaxLength")
interface ReactionRepository {
suspend fun save(reaction: Reaction): Reaction
suspend fun findById(reactionId: ReactionId): Reaction?

View File

@ -9,6 +9,8 @@ interface TimelineRepository {
suspend fun findByIds(ids: List<TimelineId>): List<Timeline>
suspend fun findById(id: TimelineId): Timeline?
@Suppress("FunctionMaxLength")
suspend fun findAllByUserDetailIdAndVisibilityIn(
userDetailId: UserDetailId,
visibility: List<TimelineVisibility>

View File

@ -18,9 +18,7 @@ class TimelineRelationship(
return id == other.id
}
override fun hashCode(): Int {
return id.hashCode()
}
override fun hashCode(): Int = id.hashCode()
}
enum class Visible {

View File

@ -6,7 +6,5 @@ import org.springframework.stereotype.Service
@Service
class EmojiKtUnicodeEmojiService : UnicodeEmojiService {
override fun isUnicodeEmoji(emoji: String): Boolean {
return Emojis.allEmojis.singleOrNull { it.char == emoji } != null
}
override fun isUnicodeEmoji(emoji: String): Boolean = Emojis.allEmojis.singleOrNull { it.char == emoji } != null
}

View File

@ -17,6 +17,9 @@ import dev.usbharu.hideout.core.infrastructure.exposedrepository.Reactions as Ex
@Repository
class ExposedReactionsQueryService : ReactionsQueryService, AbstractRepository() {
override val logger: Logger
get() = Companion.logger
override suspend fun findAllByPostId(postId: PostId): List<Reactions> {
return query {
ExposedrepositoryReactions.leftJoin(CustomEmojis).selectAll()
@ -52,21 +55,18 @@ class ExposedReactionsQueryService : ReactionsQueryService, AbstractRepository()
.groupBy(ExposedrepositoryReactions.postId)
.map {
Reactions(
it[ExposedrepositoryReactions.postId],
it[ExposedrepositoryReactions.postId.count()].toInt(),
it.getOrNull(CustomEmojis.name)
postId = it[ExposedrepositoryReactions.postId],
count = it[ExposedrepositoryReactions.postId.count()].toInt(),
name = it.getOrNull(CustomEmojis.name)
?: it[ExposedrepositoryReactions.unicodeEmoji.max<String, String>()]!!,
it.getOrNull(CustomEmojis.domain) ?: UnicodeEmoji.domain.domain,
it.getOrNull(CustomEmojis.url)?.let { it1 -> URI.create(it1) },
it[actorIdsQuery].split(",").mapNotNull { it.toLongOrNull() }
domain = it.getOrNull(CustomEmojis.domain) ?: UnicodeEmoji.domain.domain,
url = it.getOrNull(CustomEmojis.url)?.let { it1 -> URI.create(it1) },
actorIds = it[actorIdsQuery].split(",").mapNotNull { s -> s.toLongOrNull() }
)
}
}
}
override val logger: Logger
get() = Companion.logger
companion object {
private val logger = LoggerFactory.getLogger(ExposedReactionsQueryService::class.java)
}

View File

@ -76,7 +76,7 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi
mediaDetailList = it.mapNotNull { resultRow ->
resultRow.toMediaOrNull()?.let { it1 -> MediaDetail.of(it1) }
},
favourited = it.any { it.getOrNull(Reactions.actorId) != null }
favourited = it.any { resultRow -> resultRow.getOrNull(Reactions.actorId) != null }
)
}
}
@ -108,7 +108,7 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi
deleted = it[authorizedQuery[Posts.deleted]],
mediaDetailList = emptyList(),
moveTo = null,
emptyList(),
reactionsList = emptyList(),
favourited = false
)
}

View File

@ -108,12 +108,12 @@ class ExposedReactionRepository(override val domainEventPublisher: DomainEventPu
fun ResultRow.toReaction(): Reaction {
return Reaction(
ReactionId(this[Reactions.id]),
PostId(this[Reactions.postId]),
ActorId(this[Reactions.actorId]),
this[Reactions.customEmojiId]?.let { CustomEmojiId(it) },
UnicodeEmoji(this[Reactions.unicodeEmoji]),
this[Reactions.createdAt]
id = ReactionId(this[Reactions.id]),
postId = PostId(this[Reactions.postId]),
actorId = ActorId(this[Reactions.actorId]),
customEmojiId = this[Reactions.customEmojiId]?.let { CustomEmojiId(it) },
unicodeEmoji = UnicodeEmoji(this[Reactions.unicodeEmoji]),
createdAt = this[Reactions.createdAt]
)
}

View File

@ -160,9 +160,8 @@ open class DefaultTimelineStore(
override suspend fun getMedias(mediaIds: List<MediaId>): Map<MediaId, Media> =
mediaRepository.findByIds(mediaIds).associateBy { it.id }
override suspend fun getReactions(postIds: List<PostId>): Map<PostId, List<Reactions>> {
return reactionsQueryService.findAllByPostIdIn(postIds).groupBy { PostId(it.postId) }
}
override suspend fun getReactions(postIds: List<PostId>): Map<PostId, List<Reactions>> =
reactionsQueryService.findAllByPostIdIn(postIds).groupBy { PostId(it.postId) }
override suspend fun getUserDetails(userDetailIdList: List<UserDetailId>): Map<UserDetailId, UserDetail> =
userDetailRepository.findAllById(userDetailIdList).associateBy { it.id }