diff options
author | Joris Guyonvarch | 2015-08-09 00:21:03 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-08-09 00:21:03 +0200 |
commit | 169d52bfbe8b7f95dcece3cef245cdd62336e2f8 (patch) | |
tree | 491b5edb2646b41d36920f1c670cba26a674868c /src/server/View | |
parent | a4f60df0f3b72553380bdd3ca960abf42048ed7e (diff) |
Wording for sign in email
Diffstat (limited to 'src/server/View')
-rw-r--r-- | src/server/View/Mail/SignIn.hs | 48 | ||||
-rw-r--r-- | src/server/View/Page.hs | 1 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/server/View/Mail/SignIn.hs b/src/server/View/Mail/SignIn.hs new file mode 100644 index 0000000..e11b876 --- /dev/null +++ b/src/server/View/Mail/SignIn.hs @@ -0,0 +1,48 @@ +{-# LANGUAGE OverloadedStrings #-} + +module View.Mail.SignIn + ( getMail + ) where + +import Data.Text (Text) +import qualified Data.Text.Lazy as LT +import Data.Text.Lazy.Builder (toLazyText, fromText) + +import Text.Blaze.Html +import Text.Blaze.Html5 +import Text.Blaze.Html.Renderer.Text (renderHtml) + +import Model.Database (User(..)) +import qualified Model.Mail as M + +getMail :: User -> Text -> [Text] -> M.Mail +getMail user url to = + M.Mail + { M.to = to + , M.subject = "Sign in to Shared Cost" + , M.plainBody = plainBody user url + , M.htmlBody = htmlBody user url + } + +plainBody :: User -> Text -> LT.Text +plainBody user url = + LT.intercalate + "\n" + [ LT.concat ["Hi ", strictToLazy . userName $ user, ","] + , "" + , "Click to the following link in order to sign in to Shared Cost:" + , strictToLazy url + ] + +htmlBody :: User -> Text -> LT.Text +htmlBody user url = + renderHtml . docTypeHtml . body $ do + toHtml $ LT.concat ["Hi ", strictToLazy . userName $ user, ","] + br + br + "Click to the following link in order to sign in to Shared Cost:" + br + toHtml url + +strictToLazy :: Text -> LT.Text +strictToLazy = toLazyText . fromText diff --git a/src/server/View/Page.hs b/src/server/View/Page.hs index a397a96..5b9f06e 100644 --- a/src/server/View/Page.hs +++ b/src/server/View/Page.hs @@ -5,6 +5,7 @@ module View.Page ) where import Data.Text.Internal.Lazy (Text) +import Data.Text.Internal.Lazy as TL import Text.Blaze.Html import Text.Blaze.Html5 |