notification on notification settings change
This commit is contained in:
parent
848f00cfdf
commit
c173c6005a
3 changed files with 22 additions and 3 deletions
|
@ -59,7 +59,7 @@ notifyUser user bev price master = do
|
||||||
True ->
|
True ->
|
||||||
case userEmail user of
|
case userEmail user of
|
||||||
Just email ->
|
Just email ->
|
||||||
sendMail email "Einkauf beim Matematen"
|
liftIO $ sendMail email "Einkauf beim Matematen"
|
||||||
[stext|
|
[stext|
|
||||||
Hallo #{userIdent user},
|
Hallo #{userIdent user},
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ checkAlert bId = do
|
||||||
True -> do
|
True -> do
|
||||||
master <- getYesod
|
master <- getYesod
|
||||||
to <- return $ appEmail $ appSettings master
|
to <- return $ appEmail $ appSettings master
|
||||||
sendMail to "Niedriger Bestand"
|
liftIO $ sendMail to "Niedriger Bestand"
|
||||||
[stext|
|
[stext|
|
||||||
Hallo,
|
Hallo,
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ der Matemat
|
||||||
|
|
||||||
--sendMail :: MonadIO m => Text -> Text -> Text -> m ()
|
--sendMail :: MonadIO m => Text -> Text -> Text -> m ()
|
||||||
sendMail to subject body =
|
sendMail to subject body =
|
||||||
liftIO $ renderSendMail
|
renderSendMail
|
||||||
Mail
|
Mail
|
||||||
{ mailFrom = Address Nothing "noreply"
|
{ mailFrom = Address Nothing "noreply"
|
||||||
, mailTo = [Address Nothing to]
|
, mailTo = [Address Nothing to]
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
module Handler.NewUser where
|
module Handler.NewUser where
|
||||||
|
|
||||||
import Import as I
|
import Import as I
|
||||||
|
import Handler.Common
|
||||||
import Text.Read
|
import Text.Read
|
||||||
|
import Text.Shakespeare.Text
|
||||||
|
import Data.Maybe
|
||||||
|
|
||||||
getNewUserR :: Handler Html
|
getNewUserR :: Handler Html
|
||||||
getNewUserR = do
|
getNewUserR = do
|
||||||
|
@ -62,6 +65,7 @@ postModifyUserR uId = do
|
||||||
[ UserEmail =. userConfEmail conf
|
[ UserEmail =. userConfEmail conf
|
||||||
, UserNotify =. userConfNotify conf
|
, UserNotify =. userConfNotify conf
|
||||||
]
|
]
|
||||||
|
liftIO $ notify user conf
|
||||||
setMessage "Nutzerdaten aktualisiert"
|
setMessage "Nutzerdaten aktualisiert"
|
||||||
redirect $ SelectR uId
|
redirect $ SelectR uId
|
||||||
_ -> do
|
_ -> do
|
||||||
|
@ -75,3 +79,18 @@ modifyUserForm :: User -> Form UserConf
|
||||||
modifyUserForm user = renderDivs $ UserConf
|
modifyUserForm user = renderDivs $ UserConf
|
||||||
<$> aopt emailField "E-Mail" (Just $ userEmail user)
|
<$> aopt emailField "E-Mail" (Just $ userEmail user)
|
||||||
<*> areq boolField "Benachrichtigung bei Kauf" (Just $ userNotify 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
|
||||||
|
|]
|
||||||
|
|
Loading…
Reference in a new issue