diff options
author | tv <tv@krebsco.de> | 2020-09-30 11:45:41 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2020-09-30 15:39:23 +0200 |
commit | 63bf1907d3e6629ac21da87b9e45303bcec2bdf9 (patch) | |
tree | eebf73eec52795524f7cdcba6cc32272521565a0 /src/Notmuch.hs | |
parent | f8b93d1f7150f6122ecf145936b9ac1abf413e2b (diff) |
render non-text parts
Diffstat (limited to 'src/Notmuch.hs')
-rw-r--r-- | src/Notmuch.hs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/Notmuch.hs b/src/Notmuch.hs index 0781650..080df1e 100644 --- a/src/Notmuch.hs +++ b/src/Notmuch.hs @@ -11,6 +11,8 @@ import Control.Concurrent import Control.DeepSeq (rnf) import Control.Exception import Data.Aeson.Extends +import Data.Either.Combinators (mapRight) +import Data.Functor ((<&>)) import Data.Tree import Notmuch.Class import Notmuch.Message @@ -187,9 +189,21 @@ notmuchShowPart term partId = do notmuch' [ "show", "--format=json", "--format-version=2" , "--part=" <> show partId , term ] - return $ case exitCode of - ExitSuccess -> eitherDecodeLenient' out - _ -> Left $ show exitCode <> ": " <> LBS8.unpack err + case exitCode of + ExitSuccess -> + case eitherDecodeLenient' out of + Right mp -> do + case partContent mp of + ContentRaw "" contentLength -> + notmuchShowPartRaw term partId <&> mapRight (\raw -> + mp { partContent = ContentRaw raw contentLength } + ) + _ -> + return $ Right mp + Left err2 -> + return $ Left err2 + _ -> + return $ Left $ show exitCode <> ": " <> LBS8.unpack err notmuchShowMail :: String -> IO (Either String M.Mail) |