core: add FromJSON instance to ChatResponse (#3129)

* Start adding FromJSON instances to ChatResponse

* progress

* FromJSON instance for ChatResponse compiles

* restore removed encodings

* remove comment

* diff

* update simplexmq, use TH for JSON

---------

Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
Alexander Bondarenko
2023-10-05 19:49:20 +01:00
committed by GitHub
co-authored by Evgeny Poberezkin
parent 27e8a81c9f
commit fc9db9c381
18 changed files with 483 additions and 209 deletions
+7 -13
View File
@@ -49,6 +49,9 @@ data CallStateTag
| CSTCallNegotiated
deriving (Show, Generic)
instance FromJSON CallStateTag where
parseJSON = J.genericParseJSON . enumJSON $ dropPrefix "CSTCall"
instance ToJSON CallStateTag where
toJSON = J.genericToJSON . enumJSON $ dropPrefix "CSTCall"
toEncoding = J.genericToEncoding . enumJSON $ dropPrefix "CSTCall"
@@ -132,7 +135,7 @@ data RcvCallInvitation = RcvCallInvitation
sharedKey :: Maybe C.Key,
callTs :: UTCTime
}
deriving (Show, Generic)
deriving (Show, Generic, FromJSON)
instance ToJSON RcvCallInvitation where
toJSON = J.genericToJSON J.defaultOptions {J.omitNothingFields = True}
@@ -157,10 +160,7 @@ data CallInvitation = CallInvitation
{ callType :: CallType,
callDhPubKey :: Maybe C.PublicKeyX25519
}
deriving (Eq, Show, Generic)
instance FromJSON CallInvitation where
parseJSON = J.genericParseJSON J.defaultOptions {J.omitNothingFields = True}
deriving (Eq, Show, Generic, FromJSON)
instance ToJSON CallInvitation where
toJSON = J.genericToJSON J.defaultOptions {J.omitNothingFields = True}
@@ -190,10 +190,7 @@ data CallOffer = CallOffer
rtcSession :: WebRTCSession,
callDhPubKey :: Maybe C.PublicKeyX25519
}
deriving (Eq, Show, Generic)
instance FromJSON CallOffer where
parseJSON = J.genericParseJSON J.defaultOptions {J.omitNothingFields = True}
deriving (Eq, Show, Generic, FromJSON)
instance ToJSON CallOffer where
toJSON = J.genericToJSON J.defaultOptions {J.omitNothingFields = True}
@@ -203,10 +200,7 @@ data WebRTCCallOffer = WebRTCCallOffer
{ callType :: CallType,
rtcSession :: WebRTCSession
}
deriving (Eq, Show, Generic)
instance FromJSON WebRTCCallOffer where
parseJSON = J.genericParseJSON J.defaultOptions {J.omitNothingFields = True}
deriving (Eq, Show, Generic, FromJSON)
instance ToJSON WebRTCCallOffer where
toJSON = J.genericToJSON J.defaultOptions {J.omitNothingFields = True}