diff --git a/src/TzBot/ProcessEvents/Common.hs b/src/TzBot/ProcessEvents/Common.hs index e270d4f..5f26379 100644 --- a/src/TzBot/ProcessEvents/Common.hs +++ b/src/TzBot/ProcessEvents/Common.hs @@ -85,8 +85,10 @@ getTextPiecesFromMessage -> m [Text] getTextPiecesFromMessage message = do let throwAwayTooShort = filter (\x -> T.compareLength x 2 == GT) - throwAwayTooShort <$> case unUnknown $ msgBlocks message of - Left unknownBlocksValue -> do + throwAwayTooShort <$> case unUnknown <$> msgBlocks message of + Nothing -> + pure $ ignoreCodeBlocksManually $ mText message + Just (Left unknownBlocksValue) -> do logWarn [int|| Failed to parse message blocks, \ trying to ignore code blocks manually @@ -96,7 +98,7 @@ getTextPiecesFromMessage message = do #{encodePrettyToTextBuilder unknownBlocksValue} |] pure $ ignoreCodeBlocksManually $ mText message - Right blocks -> do + Just (Right blocks) -> do let (pieces, exErrs) = extractPieces blocks let (l1Errs, l2Errs) = splitExtractErrors exErrs when (not $ null l1Errs) $ diff --git a/src/TzBot/Slack/API.hs b/src/TzBot/Slack/API.hs index c0200a6..c23f2bb 100644 --- a/src/TzBot/Slack/API.hs +++ b/src/TzBot/Slack/API.hs @@ -225,7 +225,7 @@ data Message = Message , mThreadId :: Maybe ThreadId , mEdited :: Bool , mSubType :: Maybe Text - , msgBlocks :: WithUnknown [MessageBlock] + , msgBlocks :: Maybe (WithUnknown [MessageBlock]) } deriving stock (Eq, Show, Generic) instance FromJSON Message where @@ -241,7 +241,7 @@ parseMessage o = do mSubType <- o .:? "subtype" mEdited <- fmap (isJust @Text) . runMaybeT $ MaybeT (o .:? "edited") >>= MaybeT . (.:? "ts") - msgBlocks <- o .: "blocks" + msgBlocks <- o .:? "blocks" pure Message {..} -- | See: https://api.slack.com/types/user