diff options
author | Jacques Comeaux <jacquesrcomeaux@gmail.com> | 2022-05-28 10:40:52 -0500 |
---|---|---|
committer | Jacques Comeaux <jacquesrcomeaux@gmail.com> | 2022-05-28 10:40:52 -0500 |
commit | 31c3566895bb717f51e986697d3452e549451f73 (patch) | |
tree | 723b9fd36af8fd6997903590948d700508f05b83 /src | |
parent | 3d3163a1028e99e5073fd39adc9aee5d76a5e5a2 (diff) |
Handle requests
Diffstat (limited to 'src')
-rw-r--r-- | src/Data/Message.hs | 9 | ||||
-rw-r--r-- | src/Tomato/.Post.hs.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | src/Tomato/Validate.hs | 2 |
3 files changed, 7 insertions, 4 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" diff --git a/src/Tomato/.Post.hs.swp b/src/Tomato/.Post.hs.swp Binary files differdeleted file mode 100644 index f823f90..0000000 --- a/src/Tomato/.Post.hs.swp +++ /dev/null diff --git a/src/Tomato/Validate.hs b/src/Tomato/Validate.hs index a3dd328..0afc4b5 100644 --- a/src/Tomato/Validate.hs +++ b/src/Tomato/Validate.hs @@ -10,7 +10,7 @@ import Data.Message (InMessage (..)) isTomato :: InMessage -> Bool isTomato m = not (hasAttach m) && - groupId m == 87220147 && + groupId m == "87220147" && isUser m && text m == "tomato" |