From 7732daecf1a4080c970c5537c46eb5473e0951d1 Mon Sep 17 00:00:00 2001 From: Matthew Peddie Date: Tue, 11 Aug 2015 12:07:59 +1000 Subject: [PATCH] Make the 'message' sub-field of an 'Item' optional (it does not occur in the 'item' objects in reaction events) --- src/Web/Slack/Types/Item.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Web/Slack/Types/Item.hs b/src/Web/Slack/Types/Item.hs index 6f8e44d..c4e78b3 100644 --- a/src/Web/Slack/Types/Item.hs +++ b/src/Web/Slack/Types/Item.hs @@ -13,7 +13,7 @@ import Web.Slack.Types.Base import Control.Lens.TH import Prelude -data Item = MessageItem ChannelId MessageUpdate +data Item = MessageItem ChannelId (Maybe MessageUpdate) | FileItem File | FileCommentItem File Comment | ChannelItem ChannelId @@ -24,7 +24,7 @@ instance FromJSON Item where parseJSON = withObject "item" (\o -> do (typ :: String) <- o .: "type" case typ of - "message" -> MessageItem <$> o .: "channel" <*> o .: "message" + "message" -> MessageItem <$> o .: "channel" <*> o .:? "message" "file" -> FileItem <$> o .: "file" "file_comment" -> FileCommentItem <$> o .: "file" <*> o .: "comment" "channel" -> ChannelItem <$> o .: "channel"