notification on notification settings change

This commit is contained in:
nek0 2015-04-09 23:03:49 +02:00
parent 848f00cfdf
commit c173c6005a
3 changed files with 22 additions and 3 deletions

View file

@ -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},

View file

@ -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]

View file

@ -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
|]