diff options
author | Gregor Kleen <aethoago@141.li> | 2017-03-08 15:04:59 +0100 |
---|---|---|
committer | Gregor Kleen <aethoago@141.li> | 2017-03-08 15:04:59 +0100 |
commit | 910997e366d146d534585a378679859199815acf (patch) | |
tree | 04d6a93fce49d682dfbc2745554d5b88d09b6fcd | |
parent | b78644e2fe649207d81a89d0af36988aed110104 (diff) | |
download | postdelay-master.tar postdelay-master.tar.gz postdelay-master.tar.bz2 postdelay-master.tar.xz postdelay-master.zip |
-rw-r--r-- | src/Simple.hs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Simple.hs b/src/Simple.hs index 68524a8..80856d3 100644 --- a/src/Simple.hs +++ b/src/Simple.hs | |||
@@ -1,4 +1,4 @@ | |||
1 | {-# LANGUAGE RecordWildCards, ApplicativeDo, FlexibleContexts #-} | 1 | {-# LANGUAGE RecordWildCards, ApplicativeDo, FlexibleContexts, ViewPatterns, OverloadedStrings #-} |
2 | 2 | ||
3 | module Main (main) where | 3 | module Main (main) where |
4 | 4 | ||
@@ -51,15 +51,16 @@ main = do | |||
51 | ] | 51 | ] |
52 | 52 | ||
53 | flip runReaderT sConfig $ do | 53 | flip runReaderT sConfig $ do |
54 | mailStr <- liftIO getContents | 54 | mailStr <- liftIO Lazy.BS.getContents |
55 | delay <- scan mailStr | 55 | delay <- scan $ Lazy.Char8.BS.unpack mailStr |
56 | let | 56 | let |
57 | (headers, body) = break (== "") $ lines mailStr | 57 | (headers, body) = break (== "") $ Lazy.Char8.BS.lines mailStr |
58 | mailStr' = unlines $ filter (not . (isPrefixOf `on` CI.foldCase) "X-Delay:") headers ++ body | 58 | headers' = filter (not . (Lazy.Char8.BS.isPrefixOf `on` CI.foldCase) "X-Delay:") headers |
59 | mailStr' = Lazy.Char8.BS.unlines $ headers' ++ body | ||
59 | 60 | ||
60 | sendNow = sendmail sender recipients $ Lazy.Char8.BS.pack mailStr' | 61 | sendNow = sendmail sender recipients mailStr' |
61 | sendLater sendDelay = pushStore . yield $ StoredMail | 62 | sendLater sendDelay = pushStore . yield $ StoredMail |
62 | { message = Lazy.Char8.BS.pack mailStr' | 63 | { message = mailStr' |
63 | , .. | 64 | , .. |
64 | } | 65 | } |
65 | maybe sendNow sendLater delay | 66 | maybe sendNow sendLater delay |