diff options
author | Raúl Benencia <rul@kalgan.cc> | 2013-09-01 21:10:33 -0300 |
---|---|---|
committer | Raúl Benencia <rul@kalgan.cc> | 2013-09-01 21:10:33 -0300 |
commit | 56b4aef769386e9fbe3b074698451e8b74489d61 (patch) | |
tree | 174d7176ae0de7308891a7c6ce4b45dbf8e87f54 /Email.hs | |
parent | 917de9c6df342d032e2b05238c7ea923da2772db (diff) |
Email mode working for almost all kind of test-emails
Diffstat (limited to 'Email.hs')
-rw-r--r-- | Email.hs | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -7,7 +7,7 @@ -} module Email where -import Codec.MIME.Type(MIMEValue(..), MIMEContent(..)) +import Codec.MIME.Type(MIMEValue(..), MIMEContent(..), showMIMEType, Type(..), MIMEType(..)) import Data.Char(toLower) import Data.List(find) @@ -15,7 +15,23 @@ getBody :: MIMEValue -> String getBody msg = case mime_val_content msg of Single c -> c - _ -> "Buggity Buggity Buggity!" + Multi mvs -> case firstTextPart mvs of + Just mv -> unwrapContent . mime_val_content $ mv + Nothing -> "Buggity Buggity Buggity!" + where + unwrapContent (Single c) = c + +-- hackish function for showing the email. In he future the logic of this +-- function should be improved. +firstTextPart [] = Nothing +firstTextPart (mv:mvs) = case mime_val_content mv of + Single c -> if isText mv then Just mv else firstTextPart mvs + Multi mvs' -> firstTextPart mvs' + + where + isText = \mv -> case (mimeType $ mime_val_type mv) of + Text text -> True + _ -> False getHeaders :: MIMEValue -> [(String,String)] getHeaders = mime_val_headers |