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| +
#{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|
+ #{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|
+ #{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
Hello #{userSlug parAuth}
+
Hello #{userSlug owner}
+