mirror of https://github.com/usbharu/Hideout.git
style: fix lint (CI)
This commit is contained in:
parent
2a1486cb4d
commit
2b2d9046d8
|
@ -29,10 +29,10 @@ class UserCreateReactionApplicationService(
|
||||||
private val unicodeEmojiService: UnicodeEmojiService
|
private val unicodeEmojiService: UnicodeEmojiService
|
||||||
) :
|
) :
|
||||||
LocalUserAbstractApplicationService<CreateReaction, Unit>(
|
LocalUserAbstractApplicationService<CreateReaction, Unit>(
|
||||||
transaction, logger
|
transaction,
|
||||||
|
logger
|
||||||
) {
|
) {
|
||||||
override suspend fun internalExecute(command: CreateReaction, principal: LocalUser) {
|
override suspend fun internalExecute(command: CreateReaction, principal: LocalUser) {
|
||||||
|
|
||||||
val postId = PostId(command.postId)
|
val postId = PostId(command.postId)
|
||||||
val post = postRepository.findById(postId) ?: throw IllegalArgumentException("Post $postId not found.")
|
val post = postRepository.findById(postId) ?: throw IllegalArgumentException("Post $postId not found.")
|
||||||
if (postReadAccessControl.isAllow(post, principal).not()) {
|
if (postReadAccessControl.isAllow(post, principal).not()) {
|
||||||
|
|
|
@ -18,7 +18,8 @@ class UserRemoveReactionApplicationService(
|
||||||
private val unicodeEmojiService: UnicodeEmojiService
|
private val unicodeEmojiService: UnicodeEmojiService
|
||||||
) :
|
) :
|
||||||
LocalUserAbstractApplicationService<RemoveReaction, Unit>(
|
LocalUserAbstractApplicationService<RemoveReaction, Unit>(
|
||||||
transaction, logger
|
transaction,
|
||||||
|
logger
|
||||||
) {
|
) {
|
||||||
override suspend fun internalExecute(command: RemoveReaction, principal: LocalUser) {
|
override suspend fun internalExecute(command: RemoveReaction, principal: LocalUser) {
|
||||||
val postId = PostId(command.postId)
|
val postId = PostId(command.postId)
|
||||||
|
|
|
@ -18,7 +18,6 @@ class Reaction(
|
||||||
val createdAt: Instant
|
val createdAt: Instant
|
||||||
) : DomainEventStorable() {
|
) : DomainEventStorable() {
|
||||||
|
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (this === other) return true
|
if (this === other) return true
|
||||||
if (javaClass != other?.javaClass) return false
|
if (javaClass != other?.javaClass) return false
|
||||||
|
@ -46,7 +45,12 @@ class Reaction(
|
||||||
createdAt: Instant
|
createdAt: Instant
|
||||||
): Reaction {
|
): Reaction {
|
||||||
return Reaction(
|
return Reaction(
|
||||||
id, postId, actorId, customEmojiId, unicodeEmoji, createdAt
|
id,
|
||||||
|
postId,
|
||||||
|
actorId,
|
||||||
|
customEmojiId,
|
||||||
|
unicodeEmoji,
|
||||||
|
createdAt
|
||||||
).apply { addDomainEvent(ReactionEventFactory(this).createEvent(ReactionEvent.CREATE)) }
|
).apply { addDomainEvent(ReactionEventFactory(this).createEvent(ReactionEvent.CREATE)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ class ExposedReactionsQueryService : ReactionsQueryService, AbstractRepository()
|
||||||
|
|
||||||
override suspend fun findAllByPostIdIn(postIds: List<PostId>): List<Reactions> {
|
override suspend fun findAllByPostIdIn(postIds: List<PostId>): List<Reactions> {
|
||||||
return query {
|
return query {
|
||||||
|
|
||||||
val actorIdsQuery =
|
val actorIdsQuery =
|
||||||
ExposedrepositoryReactions.actorId.castTo<String>(VarCharColumnType()).groupConcat(",", true)
|
ExposedrepositoryReactions.actorId.castTo<String>(VarCharColumnType()).groupConcat(",", true)
|
||||||
|
|
||||||
|
|
|
@ -61,10 +61,12 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi
|
||||||
.leftJoin(iconMedia, { Actors.icon }, { iconMedia[Media.id] })
|
.leftJoin(iconMedia, { Actors.icon }, { iconMedia[Media.id] })
|
||||||
.leftJoin(PostsMedia, { authorizedQuery[Posts.id] }, { PostsMedia.postId })
|
.leftJoin(PostsMedia, { authorizedQuery[Posts.id] }, { PostsMedia.postId })
|
||||||
.leftJoin(Media, { PostsMedia.mediaId }, { Media.id })
|
.leftJoin(Media, { PostsMedia.mediaId }, { Media.id })
|
||||||
.leftJoin(Reactions,
|
.leftJoin(
|
||||||
|
Reactions,
|
||||||
{ authorizedQuery[Posts.id] },
|
{ authorizedQuery[Posts.id] },
|
||||||
{ Reactions.postId },
|
{ Reactions.postId },
|
||||||
{ Reactions.id isDistinctFrom principal.actorId.id })
|
{ Reactions.id isDistinctFrom principal.actorId.id }
|
||||||
|
)
|
||||||
.selectAll()
|
.selectAll()
|
||||||
.where { authorizedQuery[Posts.id] inList idList.map { it.id } }
|
.where { authorizedQuery[Posts.id] inList idList.map { it.id } }
|
||||||
.groupBy { it[authorizedQuery[Posts.id]] }
|
.groupBy { it[authorizedQuery[Posts.id]] }
|
||||||
|
@ -73,7 +75,8 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi
|
||||||
toPostDetail(it.first(), authorizedQuery, iconMedia).copy(
|
toPostDetail(it.first(), authorizedQuery, iconMedia).copy(
|
||||||
mediaDetailList = it.mapNotNull { resultRow ->
|
mediaDetailList = it.mapNotNull { resultRow ->
|
||||||
resultRow.toMediaOrNull()?.let { it1 -> MediaDetail.of(it1) }
|
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
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
class ExposedReactionRepository(override val domainEventPublisher: DomainEventPublisher) : ReactionRepository,
|
class ExposedReactionRepository(override val domainEventPublisher: DomainEventPublisher) :
|
||||||
AbstractRepository(), DomainEventPublishableRepository<Reaction> {
|
ReactionRepository,
|
||||||
|
AbstractRepository(),
|
||||||
|
DomainEventPublishableRepository<Reaction> {
|
||||||
|
|
||||||
override val logger: Logger
|
override val logger: Logger
|
||||||
get() = Companion.logger
|
get() = Companion.logger
|
||||||
|
|
||||||
|
|
||||||
override suspend fun save(reaction: Reaction): Reaction {
|
override suspend fun save(reaction: Reaction): Reaction {
|
||||||
return query {
|
return query {
|
||||||
Reactions.upsert {
|
Reactions.upsert {
|
||||||
|
@ -66,7 +67,9 @@ class ExposedReactionRepository(override val domainEventPublisher: DomainEventPu
|
||||||
return query {
|
return query {
|
||||||
Reactions.selectAll().where {
|
Reactions.selectAll().where {
|
||||||
Reactions.postId.eq(postId.id).and(Reactions.actorId eq actorId.id)
|
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()
|
}.empty().not()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,10 +92,11 @@ class ExposedReactionRepository(override val domainEventPublisher: DomainEventPu
|
||||||
unicodeEmoji: String
|
unicodeEmoji: String
|
||||||
): Reaction? {
|
): Reaction? {
|
||||||
return query {
|
return query {
|
||||||
|
|
||||||
Reactions.selectAll().where {
|
Reactions.selectAll().where {
|
||||||
Reactions.postId.eq(postId.id).and(Reactions.actorId eq actorId.id)
|
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()
|
}.limit(1).singleOrNull()?.toReaction()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +115,6 @@ fun ResultRow.toReaction(): Reaction {
|
||||||
UnicodeEmoji(this[Reactions.unicodeEmoji]),
|
UnicodeEmoji(this[Reactions.unicodeEmoji]),
|
||||||
this[Reactions.createdAt]
|
this[Reactions.createdAt]
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object Reactions : Table("reactions") {
|
object Reactions : Table("reactions") {
|
||||||
|
|
|
@ -47,7 +47,8 @@ class PostsController(
|
||||||
id,
|
id,
|
||||||
null,
|
null,
|
||||||
"❤"
|
"❤"
|
||||||
), principal
|
),
|
||||||
|
principal
|
||||||
)
|
)
|
||||||
return "redirect:/users/$name/posts/$id"
|
return "redirect:/users/$name/posts/$id"
|
||||||
}
|
}
|
||||||
|
@ -60,7 +61,8 @@ class PostsController(
|
||||||
id,
|
id,
|
||||||
null,
|
null,
|
||||||
"❤"
|
"❤"
|
||||||
), principal
|
),
|
||||||
|
principal
|
||||||
)
|
)
|
||||||
return "redirect:/users/$name/posts/$id"
|
return "redirect:/users/$name/posts/$id"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue