MisskeyからMastodonに来た投稿の添付メディアの説明文に文字列「null」が含まれる問題の対策
This commit is contained in:
parent
d842bd5ca1
commit
18f9aa1c15
|
@ -2,7 +2,13 @@ package jp.juggler.subwaytooter.api.entity
|
||||||
|
|
||||||
import jp.juggler.subwaytooter.api.TootParser
|
import jp.juggler.subwaytooter.api.TootParser
|
||||||
import jp.juggler.subwaytooter.pref.PrefB
|
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")
|
@Suppress("LongParameterList")
|
||||||
class TootAttachment private constructor(
|
class TootAttachment private constructor(
|
||||||
|
@ -104,6 +110,9 @@ class TootAttachment private constructor(
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* アプリ内でencodeJson()した情報をデコードする
|
||||||
|
*/
|
||||||
fun tootAttachmentJson(
|
fun tootAttachmentJson(
|
||||||
src: JsonObject,
|
src: JsonObject,
|
||||||
): TootAttachment {
|
): TootAttachment {
|
||||||
|
@ -147,8 +156,9 @@ class TootAttachment private constructor(
|
||||||
else -> TootAttachmentType.Unknown
|
else -> TootAttachmentType.Unknown
|
||||||
}
|
}
|
||||||
val url = src.string("url")
|
val url = src.string("url")
|
||||||
val description = src.string("comment")?.notBlank()
|
val description = (src.string("comment")?.notBlank()
|
||||||
?: src.string("name")?.notBlank()
|
?: src.string("name")?.notBlank())
|
||||||
|
?.takeIf { it != "null" }
|
||||||
return TootAttachment(
|
return TootAttachment(
|
||||||
blurhash = null,
|
blurhash = null,
|
||||||
description = description,
|
description = description,
|
||||||
|
@ -189,7 +199,7 @@ class TootAttachment private constructor(
|
||||||
|
|
||||||
return TootAttachment(
|
return TootAttachment(
|
||||||
blurhash = src.string("blurhash"),
|
blurhash = src.string("blurhash"),
|
||||||
description = src.string("name"),
|
description = src.string("name")?.notBlank()?.takeIf { it != "null" },
|
||||||
focusX = parseFocusValue(focus, "x"),
|
focusX = parseFocusValue(focus, "x"),
|
||||||
focusY = parseFocusValue(focus, "y"),
|
focusY = parseFocusValue(focus, "y"),
|
||||||
id = EntityId.DEFAULT,
|
id = EntityId.DEFAULT,
|
||||||
|
@ -219,7 +229,8 @@ class TootAttachment private constructor(
|
||||||
|
|
||||||
return TootAttachment(
|
return TootAttachment(
|
||||||
blurhash = src.string("blurhash"),
|
blurhash = src.string("blurhash"),
|
||||||
description = src.string("description"),
|
description = src.string("description")
|
||||||
|
?.notBlank()?.takeIf { it != "null" },
|
||||||
focusX = parseFocusValue(focus, "x"),
|
focusX = parseFocusValue(focus, "x"),
|
||||||
focusY = parseFocusValue(focus, "y"),
|
focusY = parseFocusValue(focus, "y"),
|
||||||
id = EntityId.mayDefault(src.string("id")),
|
id = EntityId.mayDefault(src.string("id")),
|
||||||
|
|
Loading…
Reference in New Issue