aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Conf.hs4
-rw-r--r--src/server/Controller/SignIn.hs2
-rw-r--r--src/server/Model/Message/Key.hs4
-rw-r--r--src/server/Model/Message/Translations.hs7
-rw-r--r--src/server/View/Mail/SignIn.hs9
5 files changed, 10 insertions, 16 deletions
diff --git a/src/server/Conf.hs b/src/server/Conf.hs
index f66eb5e..2269cf2 100644
--- a/src/server/Conf.hs
+++ b/src/server/Conf.hs
@@ -13,6 +13,7 @@ data Conf = Conf
, port :: Int
, signInExpirationMn :: Int
, currency :: Text
+ , noReplyMail :: Text
} deriving (Read, Eq, Show)
getConf :: FilePath -> IO (Either Text Conf)
@@ -23,5 +24,6 @@ getConf path =
Conf.lookup "hostname" conf <*>
Conf.lookup "port" conf <*>
Conf.lookup "signInExpirationMn" conf <*>
- Conf.lookup "currency" conf
+ Conf.lookup "currency" conf <*>
+ Conf.lookup "noReplyMail" conf
)
diff --git a/src/server/Controller/SignIn.hs b/src/server/Controller/SignIn.hs
index b87f7a1..95cfd07 100644
--- a/src/server/Controller/SignIn.hs
+++ b/src/server/Controller/SignIn.hs
@@ -46,7 +46,7 @@ signIn conf login =
Just user -> do
token <- liftIO . runDb $ createSignInToken login
let url = T.concat ["http://", hostname conf, "?signInToken=", token]
- maybeSentMail <- liftIO . sendMail $ SignIn.getMail (entityVal user) url [login]
+ maybeSentMail <- liftIO . sendMail $ SignIn.getMail conf (entityVal user) url [login]
case maybeSentMail of
Right _ ->
status ok200
diff --git a/src/server/Model/Message/Key.hs b/src/server/Model/Message/Key.hs
index b883132..e9cbf99 100644
--- a/src/server/Model/Message/Key.hs
+++ b/src/server/Model/Message/Key.hs
@@ -14,10 +14,6 @@ data Key =
SharedCost
- -- Email
-
- | NoReplyMail
-
-- Sign
| Email
diff --git a/src/server/Model/Message/Translations.hs b/src/server/Model/Message/Translations.hs
index d34f3d7..b7d9b4f 100644
--- a/src/server/Model/Message/Translations.hs
+++ b/src/server/Model/Message/Translations.hs
@@ -22,13 +22,6 @@ m l SharedCost =
English -> "Shared Cost"
French -> "Partage des frais"
--- Email
-
-m l NoReplyMail =
- case l of
- English -> "no-reply@cost.guyonvarch.me"
- French -> "pas-de-reponse@cost.guyonvarch.me"
-
-- Sign in
m l Email =
diff --git a/src/server/View/Mail/SignIn.hs b/src/server/View/Mail/SignIn.hs
index dca261d..f776ddd 100644
--- a/src/server/View/Mail/SignIn.hs
+++ b/src/server/View/Mail/SignIn.hs
@@ -13,10 +13,13 @@ import qualified Model.Mail as M
import Model.Message.Key
import Model.Message
-getMail :: User -> Text -> [Text] -> M.Mail
-getMail user url to =
+import Conf (Conf)
+import qualified Conf as Conf
+
+getMail :: Conf -> User -> Text -> [Text] -> M.Mail
+getMail conf user url to =
M.Mail
- { M.from = (getMessage NoReplyMail)
+ { M.from = Conf.noReplyMail conf
, M.to = to
, M.subject = (getMessage SignInMailTitle)
, M.plainBody = plainBody user url