]> gitweb.michael.orlitzky.com - dead/halcyon.git/blobdiff - src/Main.hs
Accept a sendmail_path on the command line.
[dead/halcyon.git] / src / Main.hs
index bd749f8ca47115b89e7f57c38301ad3f7f7f11e7..a52a73fa51d37215255d2a2b17aec5e56737d1ea 100644 (file)
@@ -41,19 +41,19 @@ message_from_status message default_date status =
 
 -- | If the given Message is not Nothing, send a copy of it for every
 -- Status in the list.
-send_messages :: Maybe Message -> [Status] -> IO ()
-send_messages maybe_message statuses =
+send_messages :: Cfg -> Maybe Message -> [Status] -> IO ()
+send_messages cfg maybe_message statuses =
   case maybe_message of
     Nothing -> return ()
     Just message -> do
       default_date <- rfc822_now
       let mfs = message_from_status message (default_date)
       let messages = map mfs statuses
-      sendmail_results <- mapM sendmail messages
+      sendmail_results <- mapM sendmail' messages
       _ <- mapM print_sendmail_result sendmail_results
       return ()
-
-
+  where
+    sendmail' = sendmail (sendmail_path cfg)
 
 -- | Display the number of skipped replies if ignore_replies is true
 --   and verbose is enabled.
@@ -123,7 +123,7 @@ recurse cfg username latest_status_id maybe_message = do
 
       _ <- mapM (putStrLn . pretty_print) good_statuses
 
-      send_messages maybe_message good_statuses
+      send_messages cfg maybe_message good_statuses
 
       let new_latest_status_id = get_max_status_id new_statuses
       do_recurse new_latest_status_id
@@ -228,8 +228,8 @@ main = do
 
 -- | A debugging tool that will parse, print, and email a single
 --   status (given by its id).
-twat_single_status :: Integer -> (Maybe Message) -> IO ()
-twat_single_status the_status_id maybe_message = do
+twat_single_status :: Cfg -> Integer -> (Maybe Message) -> IO ()
+twat_single_status cfg the_status_id maybe_message = do
     xmldata <- get_status the_status_id
 
     -- Parsing an empty result can blow up. Just pretend there are
@@ -252,6 +252,8 @@ twat_single_status the_status_id maybe_message = do
           Just message -> do
              default_date <- rfc822_now
              let messages = map (message_from_status message (default_date)) statuses
-             sendmail_results <- mapM sendmail messages
+             sendmail_results <- mapM sendmail' messages
              _ <- mapM print_sendmail_result sendmail_results
              return ()
+    where
+      sendmail' = sendmail (sendmail_path cfg)
\ No newline at end of file