diff --git a/Handler/Buy.hs b/Handler/Buy.hs index d63cf19..22b3bfe 100644 --- a/Handler/Buy.hs +++ b/Handler/Buy.hs @@ -59,7 +59,7 @@ notifyUser user bev price master = do True -> case userEmail user of Just email -> - sendMail email "Einkauf beim Matematen" + liftIO $ sendMail email "Einkauf beim Matematen" [stext| Hallo #{userIdent user}, diff --git a/Handler/Common.hs b/Handler/Common.hs index 122b445..eee3dd8 100644 --- a/Handler/Common.hs +++ b/Handler/Common.hs @@ -83,7 +83,7 @@ checkAlert bId = do True -> do master <- getYesod to <- return $ appEmail $ appSettings master - sendMail to "Niedriger Bestand" + liftIO $ sendMail to "Niedriger Bestand" [stext| Hallo, @@ -98,7 +98,7 @@ der Matemat --sendMail :: MonadIO m => Text -> Text -> Text -> m () sendMail to subject body = - liftIO $ renderSendMail + renderSendMail Mail { mailFrom = Address Nothing "noreply" , mailTo = [Address Nothing to] diff --git a/Handler/NewUser.hs b/Handler/NewUser.hs index 023ce63..113510c 100644 --- a/Handler/NewUser.hs +++ b/Handler/NewUser.hs @@ -1,7 +1,10 @@ module Handler.NewUser where import Import as I +import Handler.Common import Text.Read +import Text.Shakespeare.Text +import Data.Maybe getNewUserR :: Handler Html getNewUserR = do @@ -62,6 +65,7 @@ postModifyUserR uId = do [ UserEmail =. userConfEmail conf , UserNotify =. userConfNotify conf ] + liftIO $ notify user conf setMessage "Nutzerdaten aktualisiert" redirect $ SelectR uId _ -> do @@ -75,3 +79,18 @@ modifyUserForm :: User -> Form UserConf modifyUserForm user = renderDivs $ UserConf <$> aopt emailField "E-Mail" (Just $ userEmail user) <*> areq boolField "Benachrichtigung bei Kauf" (Just $ userNotify user) + +notify :: User -> UserConf -> IO () +notify user conf + | (userEmail user) == (userConfEmail conf) && (userNotify user) == (userConfNotify conf) = return () + | otherwise = sendMail (fromJust $ userEmail user) "Profiländerung" + [stext| +Hallo #{userIdent user}, + +deine Profileinstellungen wurden geändert. +Nur damit du Bescheid weißt. + +Grüße, + +der Matemat + |]