Skip to content

Commit

Permalink
feat: kmyblueの次のNodeInfoの表示方式に対応するようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
pantasystem committed Jan 9, 2024
1 parent 08d200d commit 71b5f92
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TootDTOEntityConverter @Inject constructor(
val instanceInfo = instanceInfoRepository.find(account.normalizedInstanceUri)
val isReactionAvailable = (instanceInfo.onFailure {
logger.error("Failed to find instance info", it)
}.getOrNull()?.isReactionAvailable ?: false) || nodeInfo?.type is NodeInfo.SoftwareType.Mastodon.Fedibird
}.getOrNull()?.isReactionAvailable ?: false) || nodeInfo?.type is NodeInfo.SoftwareType.Mastodon.Fedibird || nodeInfo?.type is NodeInfo.SoftwareType.Mastodon.Kmyblue

val urls = statusDTOs.flatMap { statusDTO ->
(statusDTO.emojiReactions?.mapNotNull {
Expand All @@ -60,6 +60,7 @@ class TootDTOEntityConverter @Inject constructor(
}
.getOrNull()?.isReactionAvailable
?: false) || nodeInfo?.type is NodeInfo.SoftwareType.Mastodon.Fedibird
|| nodeInfo?.type is NodeInfo.SoftwareType.Mastodon.Kmyblue

val urls = (statusDTO.emojiReactions?.mapNotNull {
it.url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ internal class MastodonTimelineStorePagingStoreImpl(

private suspend fun getVisibilitiesParameter(account: Account): List<String>? {
val nodeInfo = nodeInfoRepository.find(account.getHost()).getOrNull() ?: return null
return if (nodeInfo.type is NodeInfo.SoftwareType.Mastodon.Fedibird) {
return if (nodeInfo.type is NodeInfo.SoftwareType.Mastodon.Fedibird || nodeInfo.type is NodeInfo.SoftwareType.Mastodon.Kmyblue) {
listOf("public", "unlisted", "private", "limited", "direct", "personal")
} else {
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ class ReactionRepositoryImpl @Inject constructor(
}
}
Account.InstanceType.MASTODON, Account.InstanceType.PLEROMA -> {
if (nodeInfoRepository.find(account.getHost())
.getOrThrow().type !is NodeInfo.SoftwareType.Mastodon.Fedibird
val nodeInfo = nodeInfoRepository.find(account.getHost())
.getOrThrow()
if (nodeInfo.type !is NodeInfo.SoftwareType.Mastodon.Fedibird
&& nodeInfo.type !is NodeInfo.SoftwareType.Mastodon.Kmyblue
) {
if (!note.isSupportEmojiReaction) {
throw IllegalArgumentException("Mastodon is not support reaction, host:${account.getHost()}, username:${account.userName}")
Expand Down Expand Up @@ -99,8 +101,10 @@ class ReactionRepositoryImpl @Inject constructor(
.getOrThrow() != AddResult.Canceled))
}
Account.InstanceType.MASTODON, Account.InstanceType.PLEROMA -> {
if (nodeInfoRepository.find(account.getHost())
.getOrThrow().type !is NodeInfo.SoftwareType.Mastodon.Fedibird
val nodeInfo = nodeInfoRepository.find(account.getHost())
.getOrThrow()
if (nodeInfo.type !is NodeInfo.SoftwareType.Mastodon.Fedibird
&& nodeInfo.type !is NodeInfo.SoftwareType.Mastodon.Kmyblue
) {
if (!note.isSupportEmojiReaction) {
return@withContext false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ data class NodeInfo(
override val version: String,
) : Mastodon

data class Kmyblue(
override val name: String,
override val version: String,
) : Mastodon
}

sealed interface Pleroma : SoftwareType {
Expand Down Expand Up @@ -85,6 +89,7 @@ data class NodeInfo(
"pleroma" -> SoftwareType.Pleroma.Normal(version = software.version, name = software.name)
"akkoma" -> SoftwareType.Pleroma.Akkoma(version = software.version, name = software.name)
"firefish" -> SoftwareType.Firefish(version = software.version, name = software.name)
"kmyblue" -> SoftwareType.Mastodon.Kmyblue(version = software.version, name = software.name)
else -> SoftwareType.Other(version = software.version, name = software.name)
}
}
Expand Down

0 comments on commit 71b5f92

Please sign in to comment.