mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-17 03:45:01 +00:00
desktop, android: fix parser for reactions (#5629)
* desktop, android: fix parser for reactions * core: restrict API to known reactions
This commit is contained in:
+8
-3
@@ -2981,7 +2981,7 @@ sealed class MsgReaction {
|
||||
MREmojiChar.Heart -> "❤️"
|
||||
else -> emoji.value
|
||||
}
|
||||
is Unknown -> ""
|
||||
is Unknown -> "?"
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -3003,8 +3003,13 @@ object MsgReactionSerializer : KSerializer<MsgReaction> {
|
||||
return if (json is JsonObject && "type" in json) {
|
||||
when(val t = json["type"]?.jsonPrimitive?.content ?: "") {
|
||||
"emoji" -> {
|
||||
val emoji = Json.decodeFromString<MREmojiChar>(json["emoji"].toString())
|
||||
if (emoji == null) MsgReaction.Unknown(t, json) else MsgReaction.Emoji(emoji)
|
||||
val msgReaction = try {
|
||||
val emoji = Json.decodeFromString<MREmojiChar>(json["emoji"].toString())
|
||||
MsgReaction.Emoji(emoji)
|
||||
} catch (e: Throwable) {
|
||||
MsgReaction.Unknown(t, json)
|
||||
}
|
||||
msgReaction
|
||||
}
|
||||
else -> MsgReaction.Unknown(t, json)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user