diff options
Diffstat (limited to 'src/Data')
-rw-r--r-- | src/Data/Message.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Data/Message.hs b/src/Data/Message.hs index dfbc20b..c218cdc 100644 --- a/src/Data/Message.hs +++ b/src/Data/Message.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE DeriveGeneric #-} module Data.Message ( InMessage (..) , GMIUrl (..) @@ -21,15 +22,17 @@ import qualified Text.URI as URI data InMessage = InMessage { hasAttach :: !Bool - , groupId :: !Word + , groupId :: !Text , isUser :: !Bool , text :: !Text - } deriving Show + } deriving (Show, Generic) + +instance NFData InMessage instance Ae.FromJSON InMessage where parseJSON = Ae.withObject "InMessage" $ \o -> InMessage <$> (o .: "attachments" >>= Ae.withArray "attachments" (pure . not . null)) - <*> o .: "group-id" + <*> o .: "group_id" <*> ((==) ("user" :: Text) <$> o .: "sender_type") <*> o .: "text" |