core, ios: send_v2 api to send messages as JSON (to support filenames with spaces) (#604)

This commit is contained in:
Evgeny Poberezkin
2022-05-05 17:04:03 +04:00
committed by GitHub
parent 7928cdbfb8
commit e80f617840
4 changed files with 54 additions and 16 deletions
+9 -2
View File
@@ -14,7 +14,7 @@ import Control.Monad.Except
import Control.Monad.IO.Unlift
import Control.Monad.Reader
import Crypto.Random (ChaChaDRG)
import Data.Aeson (ToJSON)
import Data.Aeson (FromJSON, ToJSON)
import qualified Data.Aeson as J
import Data.ByteString.Char8 (ByteString)
import Data.Int (Int64)
@@ -103,7 +103,7 @@ data ChatCommand
| APIGetChats {pendingConnections :: Bool}
| APIGetChat ChatRef ChatPagination
| APIGetChatItems Int
| APISendMessage ChatRef (Maybe FilePath) (Maybe ChatItemId) MsgContent
| APISendMessage ChatRef ComposedMessage
| APISendMessageQuote ChatRef ChatItemId MsgContent -- TODO discontinue
| APIUpdateChatItem ChatRef ChatItemId MsgContent
| APIDeleteChatItem ChatRef ChatItemId CIDeleteMode
@@ -298,6 +298,13 @@ instance ToJSON PendingSubStatus where
toJSON = J.genericToJSON J.defaultOptions {J.omitNothingFields = True}
toEncoding = J.genericToEncoding J.defaultOptions {J.omitNothingFields = True}
data ComposedMessage = ComposedMessage
{ filePath :: Maybe FilePath,
quotedItemId :: Maybe ChatItemId,
msgContent :: MsgContent
}
deriving (Show, Generic, FromJSON)
data ChatError
= ChatError {errorType :: ChatErrorType}
| ChatErrorAgent {agentError :: AgentErrorType}