mirror of https://github.com/usbharu/Hideout.git
style: fix lint
This commit is contained in:
parent
c83b990a78
commit
905f0f7c2f
|
@ -24,7 +24,7 @@ class ObjectDeserializer : JsonDeserializer<Object>() {
|
|||
ExtendedActivityVocabulary.values().firstOrNull { it.name.equals(jsonNode.asText(), true) }
|
||||
}
|
||||
} else if (type.isValueNode) {
|
||||
ExtendedActivityVocabulary.values().firstOrNull() { it.name.equals(type.asText(), true) }
|
||||
ExtendedActivityVocabulary.values().firstOrNull { it.name.equals(type.asText(), true) }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class APLikeProcessor(
|
|||
|
||||
val emoji = if (content.startsWith(":")) {
|
||||
val tag = activity.activity.tag
|
||||
(tag.firstOrNull { it is Emoji } as Emoji?)?.let { emojiService.fetchEmoji(it).second }
|
||||
(tag.firstOrNull { it is Emoji } as? Emoji)?.let { emojiService.fetchEmoji(it).second }
|
||||
} else {
|
||||
UnicodeEmoji(content)
|
||||
}
|
||||
|
|
|
@ -83,8 +83,6 @@ class APResourceResolveServiceImpl(
|
|||
return objects == other.objects
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return objects.hashCode()
|
||||
}
|
||||
override fun hashCode(): Int = objects.hashCode()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ class InboxJobProcessor(
|
|||
logger.debug("Is verifying success? {}", verify)
|
||||
|
||||
val activityPubProcessor =
|
||||
activityPubProcessorList.firstOrNull { it.isSupported(param.type) } as ActivityPubProcessor<Object>?
|
||||
activityPubProcessorList.firstOrNull { it.isSupported(param.type) } as? ActivityPubProcessor<Object>
|
||||
|
||||
if (activityPubProcessor == null) {
|
||||
logger.warn("ActivityType {} is not support.", param.type)
|
||||
|
|
|
@ -26,9 +26,7 @@ class EmojiServiceImpl(
|
|||
return fetchEmoji(emoji)
|
||||
}
|
||||
|
||||
override suspend fun fetchEmoji(emoji: Emoji): Pair<Emoji, CustomEmoji> {
|
||||
return emoji to save(emoji)
|
||||
}
|
||||
override suspend fun fetchEmoji(emoji: Emoji): Pair<Emoji, CustomEmoji> = emoji to save(emoji)
|
||||
|
||||
private suspend fun save(emoji: Emoji): CustomEmoji {
|
||||
val domain = URL(emoji.id).host
|
||||
|
@ -51,13 +49,13 @@ class EmojiServiceImpl(
|
|||
)
|
||||
|
||||
val customEmoji1 = CustomEmoji(
|
||||
customEmojiRepository.generateId(),
|
||||
name,
|
||||
domain,
|
||||
instance.id,
|
||||
media.url,
|
||||
null,
|
||||
Instant.now()
|
||||
id = customEmojiRepository.generateId(),
|
||||
name = name,
|
||||
domain = domain,
|
||||
instanceId = instance.id,
|
||||
url = media.url,
|
||||
category = null,
|
||||
createdAt = Instant.now()
|
||||
)
|
||||
|
||||
return customEmojiRepository.save(customEmoji1)
|
||||
|
|
|
@ -113,7 +113,6 @@ class APNoteServiceImpl(
|
|||
it.id
|
||||
}
|
||||
|
||||
|
||||
val mediaList = note.attachment.map {
|
||||
mediaService.uploadRemoteMedia(
|
||||
RemoteMedia(
|
||||
|
|
|
@ -13,12 +13,6 @@ import java.sql.Connection
|
|||
@Service
|
||||
class ExposedTransaction : Transaction {
|
||||
override suspend fun <T> transaction(block: suspend () -> T): T {
|
||||
// return newSuspendedTransaction(MDCContext(), transactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED) {
|
||||
// warnLongQueriesDuration = 1000
|
||||
// addLogger(Slf4jSqlDebugLogger)
|
||||
// block()
|
||||
// }
|
||||
|
||||
return transaction(transactionIsolation = Connection.TRANSACTION_READ_COMMITTED) {
|
||||
debug = true
|
||||
warnLongQueriesDuration = 1000
|
||||
|
|
|
@ -5,6 +5,8 @@ import java.time.Instant
|
|||
sealed class Emoji {
|
||||
abstract val domain: String
|
||||
abstract val name: String
|
||||
|
||||
@Suppress("FunctionMinLength")
|
||||
abstract fun id(): String
|
||||
override fun toString(): String {
|
||||
return "Emoji(" +
|
||||
|
@ -23,16 +25,12 @@ data class CustomEmoji(
|
|||
val category: String?,
|
||||
val createdAt: Instant
|
||||
) : Emoji() {
|
||||
override fun id(): String {
|
||||
return id.toString()
|
||||
}
|
||||
override fun id(): String = id.toString()
|
||||
}
|
||||
|
||||
data class UnicodeEmoji(
|
||||
override val name: String
|
||||
) : Emoji() {
|
||||
override val domain: String = "unicode.org"
|
||||
override fun id(): String {
|
||||
return name
|
||||
}
|
||||
override fun id(): String = name
|
||||
}
|
||||
|
|
|
@ -12,9 +12,7 @@ class Nodeinfo private constructor() {
|
|||
return links == other.links
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return links.hashCode()
|
||||
}
|
||||
override fun hashCode(): Int = links.hashCode()
|
||||
}
|
||||
|
||||
class Links private constructor() {
|
||||
|
|
|
@ -4,7 +4,7 @@ import dev.usbharu.hideout.core.domain.model.emoji.Emoji
|
|||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
@Suppress("FunctionMaxLength")
|
||||
@Suppress("FunctionMaxLength", "TooManyFunction")
|
||||
interface ReactionRepository {
|
||||
suspend fun generateId(): Long
|
||||
suspend fun save(reaction: Reaction): Reaction
|
||||
|
|
|
@ -11,6 +11,9 @@ import org.springframework.stereotype.Service
|
|||
|
||||
@Service
|
||||
class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository() {
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
override suspend fun save(relationship: Relationship): Relationship = query {
|
||||
val singleOrNull = Relationships.select {
|
||||
(Relationships.actorId eq relationship.actorId).and(
|
||||
|
@ -94,9 +97,6 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
|
|||
return@query query.map { it.toRelationships() }
|
||||
}
|
||||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(RelationshipRepositoryImpl::class.java)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ import org.springframework.stereotype.Repository
|
|||
@Repository
|
||||
class CustomEmojiRepositoryImpl(private val idGenerateService: IdGenerateService) : CustomEmojiRepository,
|
||||
AbstractRepository() {
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
override suspend fun generateId(): Long = idGenerateService.generateId()
|
||||
|
||||
override suspend fun save(customEmoji: CustomEmoji): CustomEmoji = query {
|
||||
|
@ -56,22 +59,19 @@ class CustomEmojiRepositoryImpl(private val idGenerateService: IdGenerateService
|
|||
?.toCustomEmoji()
|
||||
}
|
||||
|
||||
override val logger: Logger
|
||||
get() = Companion.logger
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(CustomEmojiRepositoryImpl::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
fun ResultRow.toCustomEmoji(): CustomEmoji = CustomEmoji(
|
||||
this[CustomEmojis.id],
|
||||
this[CustomEmojis.name],
|
||||
this[CustomEmojis.domain],
|
||||
this[CustomEmojis.instanceId],
|
||||
this[CustomEmojis.url],
|
||||
this[CustomEmojis.category],
|
||||
this[CustomEmojis.createdAt]
|
||||
id = this[CustomEmojis.id],
|
||||
name = this[CustomEmojis.name],
|
||||
domain = this[CustomEmojis.domain],
|
||||
instanceId = this[CustomEmojis.instanceId],
|
||||
url = this[CustomEmojis.url],
|
||||
category = this[CustomEmojis.category],
|
||||
createdAt = this[CustomEmojis.createdAt]
|
||||
)
|
||||
|
||||
fun ResultRow.toCustomEmojiOrNull(): CustomEmoji? {
|
||||
|
|
|
@ -99,7 +99,6 @@ class ReactionRepositoryImpl(
|
|||
.and(Reactions.unicodeEmoji.eq(emoji.name))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override suspend fun findByPostId(postId: Long): List<Reaction> = query {
|
||||
|
@ -147,7 +146,6 @@ class ReactionRepositoryImpl(
|
|||
.and(Reactions.actorId.eq(actorId))
|
||||
}
|
||||
|
||||
|
||||
if (emoji is UnicodeEmoji) {
|
||||
query.andWhere { Reactions.unicodeEmoji eq emoji.name }
|
||||
} else {
|
||||
|
@ -178,13 +176,13 @@ class ReactionRepositoryImpl(
|
|||
fun ResultRow.toReaction(): Reaction {
|
||||
val emoji = if (this[Reactions.customEmojiId] != null) {
|
||||
CustomEmoji(
|
||||
this[Reactions.customEmojiId]!!,
|
||||
this[CustomEmojis.name],
|
||||
this[CustomEmojis.domain],
|
||||
this[CustomEmojis.instanceId],
|
||||
this[CustomEmojis.url],
|
||||
this[CustomEmojis.category],
|
||||
this[CustomEmojis.createdAt]
|
||||
id = this[Reactions.customEmojiId]!!,
|
||||
name = this[CustomEmojis.name],
|
||||
domain = this[CustomEmojis.domain],
|
||||
instanceId = this[CustomEmojis.instanceId],
|
||||
url = this[CustomEmojis.url],
|
||||
category = this[CustomEmojis.category],
|
||||
createdAt = this[CustomEmojis.createdAt]
|
||||
)
|
||||
} else if (this[Reactions.unicodeEmoji] != null) {
|
||||
UnicodeEmoji(this[Reactions.unicodeEmoji]!!)
|
||||
|
|
|
@ -26,11 +26,6 @@ class UserDetailsImpl(
|
|||
accountNonLocked: Boolean,
|
||||
authorities: MutableCollection<out GrantedAuthority>?
|
||||
) : User(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities) {
|
||||
companion object {
|
||||
@Serial
|
||||
private const val serialVersionUID: Long = -899168205656607781L
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "UserDetailsImpl(" +
|
||||
"id=$id" +
|
||||
|
@ -53,6 +48,11 @@ class UserDetailsImpl(
|
|||
result = 31 * result + id.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
companion object {
|
||||
@Serial
|
||||
private const val serialVersionUID: Long = -899168205656607781L
|
||||
}
|
||||
}
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY)
|
||||
|
|
|
@ -10,9 +10,7 @@ sealed class SavedMedia(val success: Boolean) {
|
|||
return success == other.success
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return success.hashCode()
|
||||
}
|
||||
override fun hashCode(): Int = success.hashCode()
|
||||
}
|
||||
|
||||
class SuccessSavedMedia(
|
||||
|
|
|
@ -161,7 +161,7 @@ class StatusQueryServiceImpl : StatusQueryService {
|
|||
mediaAttachments = it.mapNotNull { resultRow ->
|
||||
resultRow.toMediaOrNull()?.toMediaAttachments()
|
||||
},
|
||||
emojis = it.mapNotNull { resultRow -> resultRow.toCustomEmoji()?.toMastodonEmoji() }
|
||||
emojis = it.mapNotNull { resultRow -> resultRow.toCustomEmojiOrNull()?.toMastodonEmoji() }
|
||||
) to it.first()[Posts.repostId]
|
||||
}
|
||||
return resolveReplyAndRepost(pairs)
|
||||
|
|
|
@ -39,7 +39,5 @@ class MastodonStatusesApiContoller(private val statusesApiService: StatusesApiSe
|
|||
return ResponseEntity.ok(statusesApiService.emojiReactions(id.toLong(), uid, emoji))
|
||||
}
|
||||
|
||||
override suspend fun apiV1StatusesIdGet(id: String): ResponseEntity<Status> {
|
||||
return super.apiV1StatusesIdGet(id)
|
||||
}
|
||||
override suspend fun apiV1StatusesIdGet(id: String): ResponseEntity<Status> = super.apiV1StatusesIdGet(id)
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ interface StatusesApiService {
|
|||
}
|
||||
|
||||
@Service
|
||||
@Suppress("LongParameterList")
|
||||
class StatsesApiServiceImpl(
|
||||
private val postService: PostService,
|
||||
private val accountService: AccountService,
|
||||
|
@ -155,7 +156,6 @@ class StatsesApiServiceImpl(
|
|||
}
|
||||
|
||||
override suspend fun emojiReactions(postId: Long, userId: Long, emojiName: String): Status? {
|
||||
|
||||
status(statusQueryService.findByPostId(postId), userId) ?: return null
|
||||
|
||||
val emoji = try {
|
||||
|
@ -164,9 +164,9 @@ class StatsesApiServiceImpl(
|
|||
} else {
|
||||
emojiService.findByEmojiName(emojiName)!!
|
||||
}
|
||||
} catch (e: IllegalStateException) {
|
||||
} catch (_: IllegalStateException) {
|
||||
UnicodeEmoji("❤")
|
||||
} catch (e: NullPointerException) {
|
||||
} catch (_: NullPointerException) {
|
||||
UnicodeEmoji("❤")
|
||||
}
|
||||
reactionService.sendReaction(emoji, userId, postId)
|
||||
|
@ -174,7 +174,6 @@ class StatsesApiServiceImpl(
|
|||
}
|
||||
|
||||
override suspend fun removeEmojiReactions(postId: Long, userId: Long, emojiName: String): Status? {
|
||||
|
||||
reactionService.removeReaction(userId, postId)
|
||||
|
||||
return status(statusQueryService.findByPostId(postId), userId)
|
||||
|
|
|
@ -4,15 +4,11 @@ import Emojis
|
|||
|
||||
object EmojiUtil {
|
||||
|
||||
|
||||
val emojiMap by lazy {
|
||||
Emojis.allEmojis
|
||||
.associate { it.code.replace(" ", "-") to it.char }
|
||||
.filterValues { it != "™" }
|
||||
|
||||
}
|
||||
|
||||
fun isEmoji(string: String): Boolean {
|
||||
return emojiMap.any { it.value == string }
|
||||
}
|
||||
fun isEmoji(string: String): Boolean = emojiMap.any { it.value == string }
|
||||
}
|
||||
|
|
|
@ -19,7 +19,5 @@ class TempFile<T : Path?>(val path: T) : AutoCloseable {
|
|||
return path == other.path
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return path?.hashCode() ?: 0
|
||||
}
|
||||
override fun hashCode(): Int = path?.hashCode() ?: 0
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue