]> Git — Sourcephile - gargantext.git/blob - bin/gargantext-invitations/Main.hs
[VERSION] +1 to 0.0.6.9.2
[gargantext.git] / bin / gargantext-invitations / Main.hs
1 {-|
2 Module : Main.hs
3 Description : GarganText Mailing Invitations
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10
11 -}
12
13 {-# LANGUAGE Strict #-}
14
15 module Main where
16
17 import Data.Either (Either(..))
18 import Gargantext.API.Dev (withDevEnv, runCmdDev)
19 import Gargantext.API.Node () -- instances only
20 import Gargantext.API.Prelude (GargError)
21 import Gargantext.Core.Types.Individu (User(..), arbitraryNewUsers, NewUser(..), arbitraryUsername, GargPassword(..))
22 import Gargantext.Database.Action.Flow (getOrMkRoot, getOrMk_RootWithCorpus)
23 import Gargantext.Database.Admin.Config (userMaster, corpusMasterName)
24 import Gargantext.Database.Admin.Trigger.Init (initFirstTriggers, initLastTriggers)
25 import Gargantext.Database.Admin.Types.Hyperdata (HyperdataCorpus)
26 import Gargantext.Database.Admin.Types.Node
27 import Gargantext.Database.Prelude (CmdR)
28 import Gargantext.Database.Query.Table.Node (getOrMkList)
29 import Gargantext.Database.Query.Table.User (insertNewUsers, )
30 import Gargantext.Prelude
31 import Gargantext.Prelude.Config (GargConfig(..), readConfig)
32 import Prelude (getLine, read)
33 import System.Environment (getArgs)
34 import Gargantext.Database.Action.User.New (newUsers)
35 import Gargantext.Core.Types.Individu (User(..))
36 import qualified Gargantext.API.Node.Share as Share
37
38 main :: IO ()
39 main = do
40 params@[iniPath,user,node_id,email] <- getArgs
41
42 _ <- if length params /= 4
43 then panic "USAGE: ./gargantext-init gargantext.ini username node_id student@university.edu"
44 else pure ()
45
46 cfg <- readConfig iniPath
47
48 let invite :: CmdR GargError Int
49 invite = Share.api (UserName $ cs user) (NodeId $ (read node_id :: Int)) (Share.ShareTeamParams $ cs email)
50
51 withDevEnv iniPath $ \env -> do
52 _ <- runCmdDev env invite
53 pure ()