mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-26 19:35:48 +00:00
Merge branch 'stable'
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user