mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-24 10:55:33 +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:
+2
-2
@@ -8463,8 +8463,8 @@ chatCommandP =
|
||||
"/_update item " *> (APIUpdateChatItem <$> chatRefP <* A.space <*> A.decimal <*> liveMessageP <* A.space <*> msgContentP),
|
||||
"/_delete item " *> (APIDeleteChatItem <$> chatRefP <*> _strP <*> _strP),
|
||||
"/_delete member item #" *> (APIDeleteMemberChatItem <$> A.decimal <*> _strP),
|
||||
"/_reaction " *> (APIChatItemReaction <$> chatRefP <* A.space <*> A.decimal <* A.space <*> onOffP <* A.space <*> jsonP),
|
||||
"/_reaction members " *> (APIGetReactionMembers <$> A.decimal <* " #" <*> A.decimal <* A.space <*> A.decimal <* A.space <*> jsonP),
|
||||
"/_reaction " *> (APIChatItemReaction <$> chatRefP <* A.space <*> A.decimal <* A.space <*> onOffP <* A.space <*> (knownReaction <$?> jsonP)),
|
||||
"/_reaction members " *> (APIGetReactionMembers <$> A.decimal <* " #" <*> A.decimal <* A.space <*> A.decimal <* A.space <*> (knownReaction <$?> jsonP)),
|
||||
"/_forward plan " *> (APIPlanForwardChatItems <$> chatRefP <*> _strP),
|
||||
"/_forward " *> (APIForwardChatItems <$> chatRefP <* A.space <*> chatRefP <*> _strP <*> sendMessageTTLP),
|
||||
"/_read user " *> (APIUserRead <$> A.decimal),
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user