From 18f9aa1c15b2924ff1bdc2c8ca3b90d60e7e24bd Mon Sep 17 00:00:00 2001 From: tateisu Date: Thu, 4 Jan 2024 14:10:52 +0900 Subject: [PATCH] =?UTF-8?q?Misskey=E3=81=8B=E3=82=89Mastodon=E3=81=AB?= =?UTF-8?q?=E6=9D=A5=E3=81=9F=E6=8A=95=E7=A8=BF=E3=81=AE=E6=B7=BB=E4=BB=98?= =?UTF-8?q?=E3=83=A1=E3=83=87=E3=82=A3=E3=82=A2=E3=81=AE=E8=AA=AC=E6=98=8E?= =?UTF-8?q?=E6=96=87=E3=81=AB=E6=96=87=E5=AD=97=E5=88=97=E3=80=8Cnull?= =?UTF-8?q?=E3=80=8D=E3=81=8C=E5=90=AB=E3=81=BE=E3=82=8C=E3=82=8B=E5=95=8F?= =?UTF-8?q?=E9=A1=8C=E3=81=AE=E5=AF=BE=E7=AD=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subwaytooter/api/entity/TootAttachment.kt | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/jp/juggler/subwaytooter/api/entity/TootAttachment.kt b/app/src/main/java/jp/juggler/subwaytooter/api/entity/TootAttachment.kt index 9f1d321d..925bb203 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/api/entity/TootAttachment.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/api/entity/TootAttachment.kt @@ -2,7 +2,13 @@ package jp.juggler.subwaytooter.api.entity import jp.juggler.subwaytooter.api.TootParser import jp.juggler.subwaytooter.pref.PrefB -import jp.juggler.util.data.* +import jp.juggler.util.data.JsonObject +import jp.juggler.util.data.addTo +import jp.juggler.util.data.buildJsonObject +import jp.juggler.util.data.clip +import jp.juggler.util.data.mayUri +import jp.juggler.util.data.notBlank +import jp.juggler.util.data.notEmpty @Suppress("LongParameterList") class TootAttachment private constructor( @@ -104,6 +110,9 @@ class TootAttachment private constructor( return null } + /** + * アプリ内でencodeJson()した情報をデコードする + */ fun tootAttachmentJson( src: JsonObject, ): TootAttachment { @@ -147,8 +156,9 @@ class TootAttachment private constructor( else -> TootAttachmentType.Unknown } val url = src.string("url") - val description = src.string("comment")?.notBlank() - ?: src.string("name")?.notBlank() + val description = (src.string("comment")?.notBlank() + ?: src.string("name")?.notBlank()) + ?.takeIf { it != "null" } return TootAttachment( blurhash = null, description = description, @@ -189,7 +199,7 @@ class TootAttachment private constructor( return TootAttachment( blurhash = src.string("blurhash"), - description = src.string("name"), + description = src.string("name")?.notBlank()?.takeIf { it != "null" }, focusX = parseFocusValue(focus, "x"), focusY = parseFocusValue(focus, "y"), id = EntityId.DEFAULT, @@ -219,7 +229,8 @@ class TootAttachment private constructor( return TootAttachment( blurhash = src.string("blurhash"), - description = src.string("description"), + description = src.string("description") + ?.notBlank()?.takeIf { it != "null" }, focusX = parseFocusValue(focus, "x"), focusY = parseFocusValue(focus, "y"), id = EntityId.mayDefault(src.string("id")),