desktop, android: fix parser for reactions (#5629)

* desktop, android: fix parser for reactions

* core: restrict API to known reactions
This commit is contained in:
Evgeny
2025-02-14 23:37:06 +00:00
committed by GitHub
parent 56eaf12840
commit dfe5a4464b
4 changed files with 23 additions and 7 deletions
+7
View File
@@ -407,6 +407,13 @@ data MsgReaction = MREmoji {emoji :: MREmojiChar} | MRUnknown {tag :: Text, json
emojiTag :: IsString a => a
emojiTag = "emoji"
knownReaction :: MsgReaction -> Either String MsgReaction
knownReaction = \case
r@MREmoji {} -> Right r
MRUnknown {} -> Left "unknown MsgReaction"
-- parseJSON for MsgReaction parses unknown emoji reactions as MRUnknown with type "emoji",
-- allowing to add new emojis in a backwards compatible way - UI shows them as ?
instance FromJSON MsgReaction where
parseJSON (J.Object v) = do
tag <- v .: "type"