mirror of
https://github.com/usbharu/Hideout.git
synced 2026-09-30 08:51:11 +00:00
feat: 絵文字リアクションAPIを修正
This commit is contained in:
+12
@@ -74,6 +74,18 @@ fun ResultRow.toCustomEmoji(): CustomEmoji = CustomEmoji(
|
||||
this[CustomEmojis.createdAt]
|
||||
)
|
||||
|
||||
fun ResultRow.toCustomEmojiOrNull(): CustomEmoji? {
|
||||
return CustomEmoji(
|
||||
id = this.getOrNull(CustomEmojis.id) ?: return null,
|
||||
name = this.getOrNull(CustomEmojis.name) ?: return null,
|
||||
domain = this.getOrNull(CustomEmojis.domain) ?: return null,
|
||||
instanceId = this[CustomEmojis.instanceId],
|
||||
url = this.getOrNull(CustomEmojis.url) ?: return null,
|
||||
category = this[CustomEmojis.category],
|
||||
createdAt = this.getOrNull(CustomEmojis.createdAt) ?: return null
|
||||
)
|
||||
}
|
||||
|
||||
object CustomEmojis : Table("emojis") {
|
||||
val id = long("id")
|
||||
val name = varchar("name", 1000)
|
||||
|
||||
+16
-1
@@ -109,7 +109,22 @@ class StatusQueryServiceImpl : StatusQueryService {
|
||||
}
|
||||
|
||||
override suspend fun findByPostId(id: Long): Status {
|
||||
TODO("Not yet implemented")
|
||||
val map = Posts
|
||||
.leftJoin(PostsMedia)
|
||||
.leftJoin(Actors)
|
||||
.leftJoin(Media)
|
||||
.select { Posts.id eq id }
|
||||
.groupBy { it[Posts.id] }
|
||||
.map { it.value }
|
||||
.map {
|
||||
toStatus(it.first()).copy(
|
||||
mediaAttachments = it.mapNotNull { resultRow ->
|
||||
resultRow.toMediaOrNull()?.toMediaAttachments()
|
||||
},
|
||||
emojis = it.mapNotNull { resultRow -> resultRow.toCustomEmojiOrNull()?.toMastodonEmoji() }
|
||||
) to it.first()[Posts.repostId]
|
||||
}
|
||||
return resolveReplyAndRepost(map).single()
|
||||
}
|
||||
|
||||
private fun resolveReplyAndRepost(pairs: List<Pair<Status, Long?>>): List<Status> {
|
||||
|
||||
+8
-2
@@ -26,11 +26,17 @@ class MastodonStatusesApiContoller(private val statusesApiService: StatusesApiSe
|
||||
}
|
||||
|
||||
override suspend fun apiV1StatusesIdEmojiReactionsEmojiDelete(id: String, emoji: String): ResponseEntity<Status> {
|
||||
return super.apiV1StatusesIdEmojiReactionsEmojiDelete(id, emoji)
|
||||
val uid =
|
||||
(SecurityContextHolder.getContext().authentication.principal as Jwt).getClaim<String>("uid").toLong()
|
||||
|
||||
return ResponseEntity.ok(statusesApiService.removeEmojiReactions(id.toLong(), uid, emoji))
|
||||
}
|
||||
|
||||
override suspend fun apiV1StatusesIdEmojiReactionsEmojiPut(id: String, emoji: String): ResponseEntity<Status> {
|
||||
return super.apiV1StatusesIdEmojiReactionsEmojiPut(id, emoji)
|
||||
val uid =
|
||||
(SecurityContextHolder.getContext().authentication.principal as Jwt).getClaim<String>("uid").toLong()
|
||||
|
||||
return ResponseEntity.ok(statusesApiService.emojiReactions(id.toLong(), uid, emoji))
|
||||
}
|
||||
|
||||
override suspend fun apiV1StatusesIdGet(id: String): ResponseEntity<Status> {
|
||||
|
||||
Reference in New Issue
Block a user