From d8eedc3e2639f0f50f0554f89dc121da4941d4d1 Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 4 Apr 2016 22:48:33 +0200 Subject: Rename birthday to event --- src/Notification.hs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/Notification.hs') diff --git a/src/Notification.hs b/src/Notification.hs index 6e6677e..60062cc 100644 --- a/src/Notification.hs +++ b/src/Notification.hs @@ -10,30 +10,30 @@ import SendMail (sendMail) import Time (formatCurrentLocale) import Model.Date (getCurrentDate, getNextWeek, SuccessiveDates) -import Model.Birthdate (Birthdate, filterBirthdayAt, filterBirthdayInside) +import Model.Event (Event, filterBirthdayAt, filterBirthdayInside) import Model.Mail (mailSubject, mailBody) -import Model.Config +import Model.Conf -notifyTodayAndNextWeek :: [Birthdate] -> Config -> IO () -notifyTodayAndNextWeek birthdates config = do +notifyTodayAndNextWeek :: [Event] -> Conf -> IO () +notifyTodayAndNextWeek events conf = do currentDate <- getCurrentDate - let birthdaysToday = filterBirthdayAt currentDate birthdates + let birthdaysToday = filterBirthdayAt currentDate events nextWeek <- getNextWeek - birthdaysNextWeek <- filterBirthdaysNextWeek config nextWeek birthdates + birthdaysNextWeek <- filterBirthdaysNextWeek conf nextWeek events if length birthdaysToday > 0 || length birthdaysNextWeek > 0 then sendMail - (mailTo config) - (mailFrom config) + (mailTo conf) + (mailFrom conf) (mailSubject birthdaysToday birthdaysNextWeek) (mailBody currentDate nextWeek birthdaysToday birthdaysNextWeek) else return () -filterBirthdaysNextWeek :: Config -> SuccessiveDates -> [Birthdate] -> IO [Birthdate] -filterBirthdaysNextWeek config nextWeek birthdates = +filterBirthdaysNextWeek :: Conf -> SuccessiveDates -> [Event] -> IO [Event] +filterBirthdaysNextWeek conf nextWeek events = (\currentDayOfWeek -> - if T.toLower currentDayOfWeek == T.toLower (dayForNextWeekNotification config) - then filterBirthdayInside nextWeek birthdates + if T.toLower currentDayOfWeek == T.toLower (dayForNextWeekNotification conf) + then filterBirthdayInside nextWeek events else [] ) <$> formatCurrentLocale "%A" -- cgit v1.2.3