mirror of https://github.com/usbharu/Hideout.git
style: fix lint
This commit is contained in:
parent
2b2d9046d8
commit
39ad5a3125
|
@ -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 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in New Issue