Merge branch 'stable'

This commit is contained in:
Evgeny Poberezkin
2025-01-06 20:18:00 +00:00
6 changed files with 91 additions and 3 deletions
+1 -2
View File
@@ -3586,7 +3586,7 @@ chatCommandP =
"/_report #" *> (APIReportMessage <$> A.decimal <* A.space <*> A.decimal <*> (" reason=" *> strP) <*> (A.space *> textP <|> pure "")),
"/report #" *> (ReportMessage <$> displayName <*> optional (" @" *> displayName) <*> _strP <* A.space <*> msgTextP),
"/_update item " *> (APIUpdateChatItem <$> chatRefP <* A.space <*> A.decimal <*> liveMessageP <* A.space <*> msgContentP),
"/_delete item " *> (APIDeleteChatItem <$> chatRefP <*> _strP <* A.space <*> ciDeleteMode),
"/_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),
@@ -3869,7 +3869,6 @@ chatCommandP =
<|> (PTBefore <$ "before=" <*> strP <* A.space <* "count=" <*> A.decimal)
mcTextP = MCText . safeDecodeUtf8 <$> A.takeByteString
msgContentP = "text " *> mcTextP <|> "json " *> jsonP
ciDeleteMode = "broadcast" $> CIDMBroadcast <|> "internal" $> CIDMInternal
chatDeleteMode =
A.choice
[ " full" *> (CDMFull <$> notifyP),
+19 -1
View File
@@ -17,6 +17,7 @@ module Simplex.Chat.Messages.CIContent where
import Data.Aeson (FromJSON, ToJSON)
import qualified Data.Aeson as J
import qualified Data.Aeson.TH as JQ
import qualified Data.Attoparsec.ByteString.Char8 as A
import Data.Int (Int64)
import Data.Text (Text)
import Data.Text.Encoding (decodeLatin1, encodeUtf8)
@@ -106,7 +107,24 @@ msgDirectionIntP = \case
data CIDeleteMode = CIDMBroadcast | CIDMInternal | CIDMInternalMark
deriving (Show)
$(JQ.deriveJSON (enumJSON $ dropPrefix "CIDM") ''CIDeleteMode)
instance StrEncoding CIDeleteMode where
strEncode = \case
CIDMBroadcast -> "broadcast"
CIDMInternal -> "internal"
CIDMInternalMark -> "internalMark"
strP =
A.takeTill (== ' ') >>= \case
"broadcast" -> pure CIDMBroadcast
"internal" -> pure CIDMInternal
"internalMark" -> pure CIDMInternalMark
_ -> fail "bad CIDeleteMode"
instance ToJSON CIDeleteMode where
toJSON = strToJSON
toEncoding = strToJEncoding
instance FromJSON CIDeleteMode where
parseJSON = strParseJSON "CIDeleteMode"
ciDeleteModeToText :: CIDeleteMode -> Text
ciDeleteModeToText = \case