diff options
author | Joris | 2016-04-04 22:48:33 +0200 |
---|---|---|
committer | Joris | 2016-04-04 22:48:33 +0200 |
commit | d8eedc3e2639f0f50f0554f89dc121da4941d4d1 (patch) | |
tree | 81bd4d0a261b0550a0501ad2f70fa52b4ee21000 /src/Notification.hs | |
parent | e66ea0b49c8f7202114df366668598026f211eba (diff) | |
download | events-d8eedc3e2639f0f50f0554f89dc121da4941d4d1.tar.gz events-d8eedc3e2639f0f50f0554f89dc121da4941d4d1.tar.bz2 events-d8eedc3e2639f0f50f0554f89dc121da4941d4d1.zip |
Rename birthday to event
Diffstat (limited to 'src/Notification.hs')
-rw-r--r-- | src/Notification.hs | 24 |
1 files changed, 12 insertions, 12 deletions
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" |