aboutsummaryrefslogtreecommitdiff
path: root/src/executable/haskell/Service
diff options
context:
space:
mode:
Diffstat (limited to 'src/executable/haskell/Service')
-rw-r--r--src/executable/haskell/Service/AdListener.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/executable/haskell/Service/AdListener.hs b/src/executable/haskell/Service/AdListener.hs
index 1025166..f0adbb8 100644
--- a/src/executable/haskell/Service/AdListener.hs
+++ b/src/executable/haskell/Service/AdListener.hs
@@ -16,6 +16,7 @@ import Model.Mail (Mail (Mail))
import Model.URL (URL)
import qualified Parser.LeboncoinParser as LeboncoinParser
import qualified Parser.OuestFranceParser as OuestFranceParser
+import qualified Parser.SeLogerParser as SeLogerParser
import qualified Service.MailService as MailService
import qualified Utils.HTTP as HTTP
import qualified Utils.Time as TimeUtils
@@ -50,7 +51,8 @@ fetchAds :: Conf -> IO [Ad]
fetchAds conf = do
leboncoinAds <- getLeboncoinAds conf
ouestFranceAds <- getOuestFranceAds conf
- let results = leboncoinAds ++ ouestFranceAds
+ seLogerAds <- getSeLogerAds conf
+ let results = leboncoinAds ++ ouestFranceAds ++ seLogerAds
if null results
then T.putStrLn "Parsed 0 results!"
else return ()
@@ -72,6 +74,14 @@ getOuestFranceAds conf =
. Conf.ouestFranceUrls
$ conf
+getSeLogerAds :: Conf -> IO [Ad]
+getSeLogerAds conf =
+ fmap (concat . map SeLogerParser.parse . rights)
+ . sequence
+ . map (HTTP.get T.decodeUtf8)
+ . Conf.seLogerUrls
+ $ conf
+
sendMail :: Conf -> [Ad] -> IO ()
sendMail conf ads =
let (title, plainBody) = Ad.renderAds ads