JSON encoding for ChatResponse and all other types used in mobile API (#226)

* JSON encoding for ChatResponse and all other types used in mobile API

* omit null corrId in response, refactor

* more JSON field names
This commit is contained in:
Evgeny Poberezkin
2022-01-26 21:20:08 +00:00
committed by GitHub
parent ecb5b0fdeb
commit 0ba4598ca2
12 changed files with 482 additions and 399 deletions
+3 -1
View File
@@ -24,7 +24,7 @@ import Data.Text (Text)
import Data.Text.Encoding (decodeLatin1, encodeUtf8)
import Database.SQLite.Simple.FromField (FromField (..))
import Database.SQLite.Simple.ToField (ToField (..))
import GHC.Generics
import GHC.Generics (Generic)
import Simplex.Chat.Types
import Simplex.Messaging.Agent.Store.SQLite (fromTextField_)
import Simplex.Messaging.Encoding.String
@@ -105,6 +105,8 @@ instance ToJSON MsgContentType where
toJSON = strToJSON
toEncoding = strToJEncoding
-- TODO - include tag and original JSON into MCUnknown so that information is not lost
-- so when it serializes back it is the same as it was and chat upgrade makes it readable
data MsgContent = MCText Text | MCUnknown
deriving (Eq, Show)