mirror of https://github.com/usbharu/Hideout.git
style: fix lint (CI)
This commit is contained in:
parent
fef08cd6ae
commit
587e87b353
|
@ -29,10 +29,10 @@ class UserCreateReactionApplicationService(
|
|||
private val unicodeEmojiService: UnicodeEmojiService
|
||||
) :
|
||||
LocalUserAbstractApplicationService<CreateReaction, Unit>(
|
||||
transaction, logger
|
||||
transaction,
|
||||
logger
|
||||
) {
|
||||
override suspend fun internalExecute(command: CreateReaction, principal: LocalUser) {
|
||||
|
||||
val postId = PostId(command.postId)
|
||||
val post = postRepository.findById(postId) ?: throw IllegalArgumentException("Post $postId not found.")
|
||||
if (postReadAccessControl.isAllow(post, principal).not()) {
|
||||
|
@ -62,4 +62,4 @@ class UserCreateReactionApplicationService(
|
|||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(UserCreateReactionApplicationService::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,8 @@ class UserRemoveReactionApplicationService(
|
|||
private val unicodeEmojiService: UnicodeEmojiService
|
||||
) :
|
||||
LocalUserAbstractApplicationService<RemoveReaction, Unit>(
|
||||
transaction, logger
|
||||
transaction,
|
||||
logger
|
||||
) {
|
||||
override suspend fun internalExecute(command: RemoveReaction, principal: LocalUser) {
|
||||
val postId = PostId(command.postId)
|
||||
|
@ -47,4 +48,4 @@ class UserRemoveReactionApplicationService(
|
|||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(UserRemoveReactionApplicationService::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,4 +19,4 @@ class ReactionEventBody(
|
|||
enum class ReactionEvent(val eventName: String) {
|
||||
CREATE("ReactionCreate"),
|
||||
DELETE("ReactionDelete"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@ sealed class Emoji {
|
|||
abstract fun id(): String
|
||||
override fun toString(): String {
|
||||
return "Emoji(" +
|
||||
"domain='$domain', " +
|
||||
"name='$name'" +
|
||||
")"
|
||||
"domain='$domain', " +
|
||||
"name='$name'" +
|
||||
")"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ class Reaction(
|
|||
val createdAt: Instant
|
||||
) : DomainEventStorable() {
|
||||
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
@ -46,8 +45,13 @@ class Reaction(
|
|||
createdAt: Instant
|
||||
): Reaction {
|
||||
return Reaction(
|
||||
id, postId, actorId, customEmojiId, unicodeEmoji, createdAt
|
||||
id,
|
||||
postId,
|
||||
actorId,
|
||||
customEmojiId,
|
||||
unicodeEmoji,
|
||||
createdAt
|
||||
).apply { addDomainEvent(ReactionEventFactory(this).createEvent(ReactionEvent.CREATE)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package dev.usbharu.hideout.core.domain.model.reaction
|
||||
|
||||
@JvmInline
|
||||
value class ReactionId(val value: Long)
|
||||
value class ReactionId(val value: Long)
|
||||
|
|
|
@ -23,4 +23,4 @@ interface ReactionRepository {
|
|||
): Reaction?
|
||||
|
||||
suspend fun delete(reaction: Reaction)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,9 +61,9 @@ class TimelineObject(
|
|||
lastUpdatedAt = Instant.now()
|
||||
isPureRepost =
|
||||
post.repostId != null &&
|
||||
post.replyId == null &&
|
||||
post.text.isEmpty() &&
|
||||
post.overview?.overview.isNullOrEmpty()
|
||||
post.replyId == null &&
|
||||
post.text.isEmpty() &&
|
||||
post.overview?.overview.isNullOrEmpty()
|
||||
warnFilters = filterResults.map { TimelineObjectWarnFilter(it.filter.id, it.matchedKeyword) }
|
||||
}
|
||||
|
||||
|
@ -133,9 +133,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(),
|
||||
|
|
|
@ -2,4 +2,4 @@ package dev.usbharu.hideout.core.domain.service.emoji
|
|||
|
||||
interface UnicodeEmojiService {
|
||||
fun isUnicodeEmoji(emoji: String): Boolean
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,4 +9,4 @@ class EmojiKtUnicodeEmojiService : UnicodeEmojiService {
|
|||
override fun isUnicodeEmoji(emoji: String): Boolean {
|
||||
return Emojis.allEmojis.singleOrNull { it.char == emoji } != null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ class ExposedReactionsQueryService : ReactionsQueryService, AbstractRepository()
|
|||
|
||||
override suspend fun findAllByPostIdIn(postIds: List<PostId>): List<Reactions> {
|
||||
return query {
|
||||
|
||||
val actorIdsQuery =
|
||||
ExposedrepositoryReactions.actorId.castTo<String>(VarCharColumnType()).groupConcat(",", true)
|
||||
|
||||
|
@ -71,4 +70,4 @@ class ExposedReactionsQueryService : ReactionsQueryService, AbstractRepository()
|
|||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(ExposedReactionsQueryService::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,10 +42,10 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi
|
|||
.select(Posts.columns)
|
||||
.where {
|
||||
Posts.visibility eq Visibility.PUBLIC.name or
|
||||
(Posts.visibility eq Visibility.UNLISTED.name) or
|
||||
(Posts.visibility eq Visibility.DIRECT.name and (PostsVisibleActors.actorId eq principal.actorId.id)) or
|
||||
(Posts.visibility eq Visibility.FOLLOWERS.name and (Relationships.blocking eq false and (relationshipsAlias[Relationships.following] eq true))) or
|
||||
(Posts.actorId eq principal.actorId.id)
|
||||
(Posts.visibility eq Visibility.UNLISTED.name) or
|
||||
(Posts.visibility eq Visibility.DIRECT.name and (PostsVisibleActors.actorId eq principal.actorId.id)) or
|
||||
(Posts.visibility eq Visibility.FOLLOWERS.name and (Relationships.blocking eq false and (relationshipsAlias[Relationships.following] eq true))) or
|
||||
(Posts.actorId eq principal.actorId.id)
|
||||
}
|
||||
.alias("authorized_table")
|
||||
}
|
||||
|
@ -61,10 +61,12 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi
|
|||
.leftJoin(iconMedia, { Actors.icon }, { iconMedia[Media.id] })
|
||||
.leftJoin(PostsMedia, { authorizedQuery[Posts.id] }, { PostsMedia.postId })
|
||||
.leftJoin(Media, { PostsMedia.mediaId }, { Media.id })
|
||||
.leftJoin(Reactions,
|
||||
.leftJoin(
|
||||
Reactions,
|
||||
{ authorizedQuery[Posts.id] },
|
||||
{ Reactions.postId },
|
||||
{ Reactions.id isDistinctFrom principal.actorId.id })
|
||||
{ Reactions.id isDistinctFrom principal.actorId.id }
|
||||
)
|
||||
.selectAll()
|
||||
.where { authorizedQuery[Posts.id] inList idList.map { it.id } }
|
||||
.groupBy { it[authorizedQuery[Posts.id]] }
|
||||
|
@ -73,7 +75,8 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi
|
|||
toPostDetail(it.first(), authorizedQuery, iconMedia).copy(
|
||||
mediaDetailList = it.mapNotNull { resultRow ->
|
||||
resultRow.toMediaOrNull()?.let { it1 -> MediaDetail.of(it1) }
|
||||
}, favourited = it.any { it.getOrNull(Reactions.actorId) != null }
|
||||
},
|
||||
favourited = it.any { it.getOrNull(Reactions.actorId) != null }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,14 @@ import org.slf4j.LoggerFactory
|
|||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
class ExposedReactionRepository(override val domainEventPublisher: DomainEventPublisher) : ReactionRepository,
|
||||
AbstractRepository(), DomainEventPublishableRepository<Reaction> {
|
||||
class ExposedReactionRepository(override val domainEventPublisher: DomainEventPublisher) :
|
||||
ReactionRepository,
|
||||
AbstractRepository(),
|
||||
DomainEventPublishableRepository<Reaction> {
|
||||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
|
||||
override suspend fun save(reaction: Reaction): Reaction {
|
||||
return query {
|
||||
Reactions.upsert {
|
||||
|
@ -66,7 +67,9 @@ class ExposedReactionRepository(override val domainEventPublisher: DomainEventPu
|
|||
return query {
|
||||
Reactions.selectAll().where {
|
||||
Reactions.postId.eq(postId.id).and(Reactions.actorId eq actorId.id)
|
||||
.and((Reactions.customEmojiId eq customEmojiId?.emojiId or (Reactions.unicodeEmoji eq unicodeEmoji)))
|
||||
.and(
|
||||
(Reactions.customEmojiId eq customEmojiId?.emojiId or (Reactions.unicodeEmoji eq unicodeEmoji))
|
||||
)
|
||||
}.empty().not()
|
||||
}
|
||||
}
|
||||
|
@ -89,10 +92,11 @@ class ExposedReactionRepository(override val domainEventPublisher: DomainEventPu
|
|||
unicodeEmoji: String
|
||||
): Reaction? {
|
||||
return query {
|
||||
|
||||
Reactions.selectAll().where {
|
||||
Reactions.postId.eq(postId.id).and(Reactions.actorId eq actorId.id)
|
||||
.and((Reactions.customEmojiId eq customEmojiId?.emojiId or (Reactions.unicodeEmoji eq unicodeEmoji)))
|
||||
.and(
|
||||
(Reactions.customEmojiId eq customEmojiId?.emojiId or (Reactions.unicodeEmoji eq unicodeEmoji))
|
||||
)
|
||||
}.limit(1).singleOrNull()?.toReaction()
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +115,6 @@ fun ResultRow.toReaction(): Reaction {
|
|||
UnicodeEmoji(this[Reactions.unicodeEmoji]),
|
||||
this[Reactions.createdAt]
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
object Reactions : Table("reactions") {
|
||||
|
@ -122,4 +125,4 @@ object Reactions : Table("reactions") {
|
|||
val unicodeEmoji = varchar("unicode_emoji", 100)
|
||||
val createdAt = timestamp("created_at")
|
||||
override val primaryKey: PrimaryKey = PrimaryKey(id)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,8 +246,8 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
|
|||
val actors =
|
||||
getActors(
|
||||
timelineObjectList.map { it.postActorId } +
|
||||
timelineObjectList.mapNotNull { it.repostActorId } +
|
||||
timelineObjectList.mapNotNull { it.replyActorId }
|
||||
timelineObjectList.mapNotNull { it.repostActorId } +
|
||||
timelineObjectList.mapNotNull { it.replyActorId }
|
||||
)
|
||||
|
||||
val postMap = posts.associate { post ->
|
||||
|
@ -256,7 +256,7 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
|
|||
|
||||
val mediaMap = getMedias(
|
||||
posts.flatMap { it.mediaIds } +
|
||||
actors.mapNotNull { it.value.icon }
|
||||
actors.mapNotNull { it.value.icon }
|
||||
)
|
||||
|
||||
val reactions = getReactions(posts.map { it.id })
|
||||
|
|
|
@ -47,7 +47,8 @@ class PostsController(
|
|||
id,
|
||||
null,
|
||||
"❤"
|
||||
), principal
|
||||
),
|
||||
principal
|
||||
)
|
||||
return "redirect:/users/$name/posts/$id"
|
||||
}
|
||||
|
@ -60,7 +61,8 @@ class PostsController(
|
|||
id,
|
||||
null,
|
||||
"❤"
|
||||
), principal
|
||||
),
|
||||
principal
|
||||
)
|
||||
return "redirect:/users/$name/posts/$id"
|
||||
}
|
||||
|
|
|
@ -6,4 +6,4 @@ import dev.usbharu.hideout.core.domain.model.post.PostId
|
|||
interface ReactionsQueryService {
|
||||
suspend fun findAllByPostId(postId: PostId): List<Reactions>
|
||||
suspend fun findAllByPostIdIn(postIds: List<PostId>): List<Reactions>
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue