From fab24614b147664c2e61c7f7af021476ba5db819 Mon Sep 17 00:00:00 2001 From: nek0 Date: Mon, 8 Dec 2014 06:13:39 +0100 Subject: [PATCH] now sendingmails on comments --- Handler/Medium.hs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Handler/Medium.hs b/Handler/Medium.hs index 262a73a..9f7a83c 100644 --- a/Handler/Medium.hs +++ b/Handler/Medium.hs @@ -1,6 +1,7 @@ module Handler.Medium where import Import +import Helper import Data.Time import Data.Maybe import qualified Data.Text as T @@ -55,6 +56,18 @@ postMediumR mediumId = do case res of FormSuccess temp -> do cId <- runDB $ insert temp + --send mail to medium owner + owner <- runDB $ getJust $ mediumOwner medium + link <- ($ MediumR (commentOrigin temp)) <$> getUrlRender + sendMail (userEmail owner) ((fromJust $ commentAuthorSlug temp) `T.append` " commented on your medium") + [shamlet| +

Hello #{userSlug owner} +

#{fromJust $ commentAuthorSlug temp} commented on your medium: +

#{commentContent temp} +

To follow the comment thread follow + + this link + |] setMessage "Your Comment has been posted" redirect $ MediumR mediumId _ -> do @@ -115,6 +128,31 @@ postCommentReplyR commentId = do case res of FormSuccess temp -> do cId <- runDB $ insert temp + --send mail to parent author + parent <- runDB $ getJust $ fromJust $ commentParent temp + parAuth <- runDB $ getJust $ fromJust $ commentAuthor parent + link <- ($ MediumR (commentOrigin temp)) <$> getUrlRender + sendMail (userEmail parAuth) ((fromJust $ commentAuthorSlug temp) `T.append` " replied to your comment") + [shamlet| +

Hello #{userSlug parAuth} +

#{fromJust $ commentAuthorSlug temp} replied to your comment: +

#{commentContent temp} +

To see the comment thread follow + + this link + |] + --send mail to medium owner + medium <- runDB $ getJust mediumId + owner <- runDB $ getJust $ mediumOwner medium + sendMail (userEmail owner) ((fromJust $ commentAuthorSlug temp) `T.append` " commented on your medium") + [shamlet| +

Hello #{userSlug owner} +

#{fromJust $ commentAuthorSlug temp} commented your medium with: +

#{commentContent temp} +

To see the comment thread follow + + this link + |] setMessage "Your reply has been posted" redirect $ MediumR mediumId _ -> do