1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{-|
Module : Gargantext.Database.Action.Mail
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE TemplateHaskell #-}
module Gargantext.Database.Action.Mail
where
import Control.Lens (view)
import Gargantext.Core.Mail (mail, MailModel(..))
import Gargantext.Core.Mail.Types (mailSettings)
import Gargantext.Core.Types.Individu (User(..))
import Gargantext.Database.Action.User
import Gargantext.Database.Prelude
import Gargantext.Database.Query.Table.Node.Error (HasNodeError(..))
import Gargantext.Database.Schema.User
import Gargantext.Prelude
import Gargantext.System.Logging (MonadLogger, LogLevel(..), logLocM)
------------------------------------------------------------------------
sendMail :: (HasNodeError err, IsDBCmdExtra env err m, MonadLogger m)
=> User -> m ()
sendMail u = do
cfg <- view $ mailSettings
userLight <- runDBQuery $ getUserLightDB u
$(logLocM) DEBUG $ "[sendMail] sending mail to user " <> show userLight
mail cfg (MailInfo { mailInfo_username = userLight_username userLight
, mailInfo_address = userLight_email userLight
}
)