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.hs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/executable/haskell/Service/AdListener.hs b/src/executable/haskell/Service/AdListener.hs
index 5cf26d1..c393f38 100644
--- a/src/executable/haskell/Service/AdListener.hs
+++ b/src/executable/haskell/Service/AdListener.hs
@@ -5,7 +5,7 @@ module Service.AdListener
import Control.Concurrent (threadDelay)
import qualified Data.Text as T
import qualified Data.Text.IO as T
-import Network.HTTP.Conduit (Manager)
+import Network.Wreq.Session (Session)
import Prelude hiding (error)
import Conf (Conf)
@@ -19,17 +19,17 @@ import qualified Service.MailService as MailService
import qualified Utils.Time as TimeUtils
import qualified View.Ad as Ad
-start :: Conf -> Manager -> IO ()
-start conf manager = do
- ads <- fetchAds conf manager
+start :: Conf -> Session -> IO ()
+start conf session = do
+ ads <- fetchAds conf session
let newURLs = map Ad.url ads
T.putStrLn "Listening to new ads…"
waitListenInterval conf
- listenToNewAdsWithViewedURLs conf manager newURLs
+ listenToNewAdsWithViewedURLs conf session newURLs
-listenToNewAdsWithViewedURLs :: Conf -> Manager -> [URL] -> IO ()
-listenToNewAdsWithViewedURLs conf manager viewedURLs = do
- ads <- fetchAds conf manager
+listenToNewAdsWithViewedURLs :: Conf -> Session -> [URL] -> IO ()
+listenToNewAdsWithViewedURLs conf session viewedURLs = do
+ ads <- fetchAds conf session
let (newURLs, newAds) = Ad.getNewAds viewedURLs ads
time <- TimeUtils.getCurrentFormattedTime
if not (null newAds)
@@ -40,13 +40,13 @@ listenToNewAdsWithViewedURLs conf manager viewedURLs = do
else
return ()
waitListenInterval conf
- listenToNewAdsWithViewedURLs conf manager (viewedURLs ++ newURLs)
+ listenToNewAdsWithViewedURLs conf session (viewedURLs ++ newURLs)
-fetchAds :: Conf -> Manager -> IO [Ad]
-fetchAds conf manager = do
- leboncoinAds <- FetchAd.leboncoin manager (Conf.leboncoinUrls conf)
- ouestFranceAds <- FetchAd.ouestFrance manager (Conf.ouestFranceUrls conf)
- seLogerAds <- FetchAd.seLoger manager (Conf.seLogerUrls conf)
+fetchAds :: Conf -> Session -> IO [Ad]
+fetchAds conf session = do
+ leboncoinAds <- FetchAd.leboncoin session (Conf.leboncoinUrls conf)
+ ouestFranceAds <- FetchAd.ouestFrance session (Conf.ouestFranceUrls conf)
+ seLogerAds <- FetchAd.seLoger session (Conf.seLogerUrls conf)
let results = leboncoinAds ++ ouestFranceAds ++ seLogerAds
T.putStrLn . T.concat $
[ "Parsed "