Refactor sending email for easier currying
This commit is contained in:
parent
49536ad05b
commit
fb69b58f92
|
@ -143,7 +143,7 @@ sendVerificationSecret email = void $ do
|
|||
maybeDBEmail <- runQuery $ get email
|
||||
let email = dBEmailEmail <$> maybeDBEmail
|
||||
secret = dBEmailVerificationSecret =<< maybeDBEmail
|
||||
args = (,) <$> email <*> secret
|
||||
args = (,) <$> secret <*> email
|
||||
maybe (pure ()) (uncurry sendVerificationEmail) args
|
||||
|
||||
updateUser :: (MonadRandom m, MonadDB m, MonadEmail m, MonadError GQLError m) =>
|
||||
|
|
|
@ -8,22 +8,22 @@ import Data.Text.Lazy (fromStrict)
|
|||
import Datarekisteri.Core.Types
|
||||
import Network.Mail.Mime
|
||||
|
||||
sendDatarekisteriEmail :: MonadEmail m => Email -> Text -> Text -> m ()
|
||||
sendDatarekisteriEmail to subject content = do
|
||||
sendDatarekisteriEmail :: MonadEmail m => Text -> Text -> Email -> m ()
|
||||
sendDatarekisteriEmail subject content to = do
|
||||
from <- fromAddress
|
||||
sendEmail $ simpleMail' (Address Nothing $ renderEmail to) from subject $ fromStrict content
|
||||
|
||||
sendVerificationEmail :: MonadEmail m => Email -> Text -> m ()
|
||||
sendVerificationEmail to secret = sendDatarekisteriEmail to "Sähköpostin vahvistuskoodi" $
|
||||
sendVerificationEmail :: MonadEmail m => Text -> Email -> m ()
|
||||
sendVerificationEmail secret = sendDatarekisteriEmail "Sähköpostin vahvistuskoodi" $
|
||||
"Vahvista sähköpostisi syöttämällä alla oleva koodi rekisteriin:\n\n"
|
||||
<> secret <> "\n\n"
|
||||
<> "Mikäli et odottanut tätä viestiä, voit jättää sen turvallisesti huomiotta."
|
||||
|
||||
sendApplicationAcceptedEmail :: MonadEmail m => Email -> m ()
|
||||
sendApplicationAcceptedEmail to = sendDatarekisteriEmail to "Jäsenhakemus hyväksytty" $
|
||||
sendApplicationAcceptedEmail = sendDatarekisteriEmail "Jäsenhakemus hyväksytty" $
|
||||
"Jäsenhakemuksesi Datat RY:lle on hyväksytty. Olet nyt yhdistyksen jäsen."
|
||||
|
||||
sendApplicationRejectedEmail :: MonadEmail m => Email -> m ()
|
||||
sendApplicationRejectedEmail to = sendDatarekisteriEmail to "Jäsenhakemus hylätty" $
|
||||
sendApplicationRejectedEmail = sendDatarekisteriEmail "Jäsenhakemus hylätty" $
|
||||
"Jäsenhakemuksesi Datat RY:lle on hylätty. Voit halutessasi kysyä hakemuksen"
|
||||
<> " hylkäämisen syistä yhdistyksen hallitukselta <hallitus@datat.fi>."
|
||||
|
|
Loading…
Reference in New Issue