Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
8ce28ab3
Verified
Commit
8ce28ab3
authored
Sep 04, 2024
by
Przemyslaw Kaminski
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[config] more config refactoring
parent
f40638e7
Pipeline
#6583
failed with stages
Changes
14
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
94 additions
and
105 deletions
+94
-105
Ini.hs
bin/gargantext-cli/CLI/Ini.hs
+11
-12
Init.hs
bin/gargantext-cli/CLI/Init.hs
+2
-1
Upgrade.hs
bin/gargantext-cli/CLI/Upgrade.hs
+2
-1
Settings.hs
src/Gargantext/API/Admin/Settings.hs
+4
-4
PolicyCheck.hs
src/Gargantext/API/Auth/PolicyCheck.hs
+2
-1
New.hs
src/Gargantext/API/Node/Corpus/New.hs
+5
-4
ShareURL.hs
src/Gargantext/API/Node/ShareURL.hs
+3
-2
Routes.hs
src/Gargantext/API/Routes.hs
+3
-2
Named.hs
src/Gargantext/API/Server/Named.hs
+4
-3
Config.hs
src/Gargantext/Core/Config.hs
+20
-59
Types.hs
src/Gargantext/Core/Config/Types.hs
+28
-9
Mail.hs
src/Gargantext/Core/Mail.hs
+5
-3
Flow.hs
src/Gargantext/Database/Action/Flow.hs
+3
-2
Node.hs
src/Gargantext/Database/Action/Node.hs
+2
-2
No files found.
bin/gargantext-cli/CLI/Ini.hs
View file @
8ce28ab3
...
...
@@ -54,18 +54,9 @@ ini_p = fmap CCMD_ini $ IniArgs
convertConfigs
::
Ini
.
GargConfig
->
IniMail
.
MailConfig
->
IniNLP
.
NLPConfig
->
PGS
.
ConnectInfo
->
Config
.
GargConfig
convertConfigs
ini
@
(
Ini
.
GargConfig
{
..
})
iniMail
nlpConfig
connInfo
=
Config
.
GargConfig
{
_gc_backend_name
,
_gc_url
,
_gc_url_backend_api
,
_gc_masteruser
,
_gc_secretkey
Config
.
GargConfig
{
_gc_secrets
=
CTypes
.
SecretsConfig
{
_s_master_user
=
_gc_masteruser
,
_s_secret_key
=
_gc_secretkey
}
,
_gc_datafilepath
,
_gc_max_docs_parsers
,
_gc_max_docs_scrapers
,
_gc_js_job_timeout
,
_gc_js_id_timeout
,
_gc_pubmed_api_key
,
_gc_epo_api_url
,
_gc_mail_config
=
iniMail
,
_gc_nlp_config
=
nlpConfig
,
_gc_frontend_config
=
mkFrontendConfig
ini
...
...
@@ -75,7 +66,15 @@ convertConfigs ini@(Ini.GargConfig { .. }) iniMail nlpConfig connInfo =
,
_f_calc_url
=
_gc_frame_calc_url
,
_f_visio_url
=
_gc_frame_visio_url
,
_f_searx_url
=
_gc_frame_searx_url
,
_f_istex_url
=
_gc_frame_istex_url
}
}
,
_f_istex_url
=
_gc_frame_istex_url
}
,
_gc_jobs
=
CTypes
.
JobsConfig
{
_jc_max_docs_parsers
=
_gc_max_docs_parsers
,
_jc_max_docs_scrapers
=
_gc_max_docs_scrapers
,
_jc_js_job_timeout
=
_gc_js_job_timeout
,
_jc_js_id_timeout
=
_gc_js_id_timeout
}
,
_gc_apis
=
CTypes
.
APIsConfig
{
_ac_pubmed_api_key
=
_gc_pubmed_api_key
,
_ac_epo_api_url
=
_gc_epo_api_url
}
}
mkFrontendConfig
::
Ini
.
GargConfig
->
CTypes
.
FrontendConfig
mkFrontendConfig
(
Ini
.
GargConfig
{
..
})
=
...
...
bin/gargantext-cli/CLI/Init.hs
View file @
8ce28ab3
...
...
@@ -23,6 +23,7 @@ import Gargantext.API.Dev (withDevEnv, runCmdDev)
import
Gargantext.API.Errors.Types
import
Gargantext.API.Node
()
-- instances only
import
Gargantext.Core.Config
(
GargConfig
(
..
))
import
Gargantext.Core.Config.Types
(
SecretsConfig
(
..
))
import
Gargantext.Core.Config.Utils
(
readConfig
)
import
Gargantext.Core.Types.Individu
(
User
(
..
),
arbitraryNewUsers
,
NewUser
(
..
),
arbitraryUsername
,
GargPassword
(
..
))
import
Gargantext.Database.Action.Flow
(
getOrMkRoot
,
getOrMkRootWithCorpus
)
...
...
@@ -47,7 +48,7 @@ initCLI (InitArgs settingsPath) = do
email
<-
getLine
cfg
<-
readConfig
settingsPath
let
secret
=
_
gc_secretkey
cfg
let
secret
=
_
s_secret_key
$
_gc_secrets
cfg
let
createUsers
::
forall
env
.
HasSettings
env
=>
DBCmd'
env
BackendInternalError
Int64
createUsers
=
insertNewUsers
(
NewUser
"gargantua"
(
cs
email
)
(
GargPassword
$
cs
password
)
...
...
bin/gargantext-cli/CLI/Upgrade.hs
View file @
8ce28ab3
...
...
@@ -22,6 +22,7 @@ import Data.List qualified as List (cycle, concat, take, unlines)
import
Gargantext.API.Dev
(
withDevEnv
)
import
Gargantext.API.Node
()
-- instances only
import
Gargantext.Core.Config
(
GargConfig
(
..
))
import
Gargantext.Core.Config.Types
(
SecretsConfig
(
..
))
import
Gargantext.Core.Config.Utils
(
readConfig
)
import
Gargantext.Prelude
import
Options.Applicative
...
...
@@ -48,7 +49,7 @@ upgradeCLI (UpgradeArgs settingsFile) = do
_ok
<-
getLine
cfg
<-
readConfig
settingsFile
let
_secret
=
_
gc_secretkey
cfg
let
_secret
=
_
s_secret_key
$
_gc_secrets
cfg
withDevEnv
settingsFile
$
\
_env
->
do
-- _ <- runCmdDev env addIndex
...
...
src/Gargantext/API/Admin/Settings.hs
View file @
8ce28ab3
...
...
@@ -32,8 +32,8 @@ import Gargantext.API.Errors.Types
import
Gargantext.API.Prelude
import
Gargantext.Core.AsyncUpdates.CentralExchange
qualified
as
CE
import
Gargantext.Core.AsyncUpdates.Dispatcher
qualified
as
D
import
Gargantext.Core.Config
(
GargConfig
(
..
),
gc_j
s_job_timeout
,
gc_js_id_timeout
)
import
Gargantext.Core.Config.Types
(
SettingsFile
(
..
),
_fc_cors
,
_fc_microservices
)
import
Gargantext.Core.Config
(
GargConfig
(
..
),
gc_j
obs
)
import
Gargantext.Core.Config.Types
(
SettingsFile
(
..
),
_fc_cors
,
_fc_microservices
,
jc_js_job_timeout
,
jc_js_id_timeout
)
import
Gargantext.Core.Config.Utils
(
readConfig
)
import
Gargantext.Core.NLP
(
nlpServerMap
)
import
Gargantext.Core.NodeStory
...
...
@@ -203,8 +203,8 @@ newEnv logger port settingsFile@(SettingsFile sf) = do
secret
<-
Jobs
.
genSecret
let
jobs_settings
=
(
Jobs
.
defaultJobSettings
1
secret
)
&
Jobs
.
l_jsJobTimeout
.~
(
fromIntegral
$
config_env
^.
hasConfig
^.
gc_js_job_timeout
)
&
Jobs
.
l_jsIDTimeout
.~
(
fromIntegral
$
config_env
^.
hasConfig
^.
gc_js_id_timeout
)
&
Jobs
.
l_jsJobTimeout
.~
(
fromIntegral
$
config_env
^.
hasConfig
^.
gc_j
obs
.
jc_j
s_job_timeout
)
&
Jobs
.
l_jsIDTimeout
.~
(
fromIntegral
$
config_env
^.
hasConfig
^.
gc_j
obs
.
jc_j
s_id_timeout
)
!
jobs_env
<-
Jobs
.
newJobEnv
jobs_settings
prios'
manager_env
!
central_exchange
<-
forkIO
$
CE
.
gServer
(
_gc_notifications_config
config_env
)
...
...
src/Gargantext/API/Auth/PolicyCheck.hs
View file @
8ce28ab3
...
...
@@ -33,6 +33,7 @@ import Gargantext.Database.Query.Table.Node.Error
import
Gargantext.Database.Query.Tree
import
Gargantext.Database.Query.Tree.Root
import
Gargantext.Core.Config
(
GargConfig
(
..
))
import
Gargantext.Core.Config.Types
(
SecretsConfig
(
..
))
import
Prelude
import
Servant
import
Servant.API.Routes
...
...
@@ -139,7 +140,7 @@ check (AuthenticatedUser loggedUserNodeId loggedUserUserId) = \case
->
enforce
err403
$
(
loggedUserUserId
==
requestedUserId
)
AC_master_user
_requestedNodeId
->
do
masterUsername
<-
_
gc_masteruser
<$>
view
hasConfig
masterUsername
<-
_
s_master_user
.
_gc_secrets
<$>
view
hasConfig
masterNodeId
<-
getRootId
(
UserName
masterUsername
)
enforce
err403
$
masterNodeId
==
loggedUserNodeId
AC_node_descendant
nodeId
...
...
src/Gargantext/API/Node/Corpus/New.hs
View file @
8ce28ab3
...
...
@@ -28,6 +28,7 @@ import Data.Swagger ( ToSchema(..) )
import
Data.Text
qualified
as
T
import
Data.Text.Encoding
qualified
as
TE
import
EPO.API.Client.Types
qualified
as
EPO
import
Gargantext.API.Admin.Orchestrator.Types
qualified
as
API
import
Gargantext.API.Admin.Types
(
HasSettings
)
import
Gargantext.API.Ngrams
(
commitStatePatch
,
Versioned
(
..
))
import
Gargantext.API.Node.Corpus.New.Types
(
FileFormat
(
..
),
FileType
(
..
)
)
...
...
@@ -36,10 +37,11 @@ import Gargantext.API.Node.Corpus.Types ( Datafield(Web), database2origin )
import
Gargantext.API.Node.Corpus.Update
(
addLanguageToCorpus
)
import
Gargantext.API.Node.Types
import
Gargantext.Core
(
withDefaultLanguage
,
defaultLanguage
)
import
Gargantext.Core.Config
(
gc_jobs
)
import
Gargantext.Core.Config.Types
(
jc_max_docs_parsers
)
import
Gargantext.Core.NodeStory
(
HasNodeStoryImmediateSaver
,
HasNodeArchiveStoryImmediateSaver
,
currentVersion
,
NgramsStatePatch
'
)
import
Gargantext.API.Admin.Orchestrator.Types
qualified
as
API
import
Gargantext.Core.Text.Corpus.Query
qualified
as
API
import
Gargantext.Core.Text.Corpus.Parsers
qualified
as
Parser
(
FileType
(
..
),
parseFormatC
,
_ParseFormatError
)
import
Gargantext.Core.Text.Corpus.Query
qualified
as
API
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Database.Action.Flow
(
flowCorpus
,
getDataText
,
flowDataText
,
TermType
(
..
)
{-, allDataOrigins-}
)
...
...
@@ -57,7 +59,6 @@ import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata)
import
Gargantext.Database.Query.Tree.Root
(
MkCorpusUser
(
MkCorpusUserNormalCorpusIds
))
import
Gargantext.Database.Schema.Node
(
node_hyperdata
)
import
Gargantext.Prelude
import
Gargantext.Core.Config
(
gc_max_docs_parsers
)
import
Gargantext.System.Logging
(
logLocM
,
LogLevel
(
..
)
)
import
Gargantext.Utils.Jobs.Monad
(
JobHandle
,
MonadJobStatus
(
..
))
...
...
@@ -237,7 +238,7 @@ addToCorpusWithForm user cid nwf jobHandle = do
let
l
=
nwf
^.
wf_lang
.
non
defaultLanguage
addLanguageToCorpus
cid
l
limit'
<-
view
$
hasConfig
.
gc_max_docs_parsers
limit'
<-
view
$
hasConfig
.
gc_
jobs
.
jc_
max_docs_parsers
let
limit
=
fromIntegral
limit'
::
Integer
let
parseC
=
case
(
nwf
^.
wf_filetype
)
of
...
...
src/Gargantext/API/Node/ShareURL.hs
View file @
8ce28ab3
...
...
@@ -10,7 +10,8 @@ import Data.Validity qualified as V
import
Gargantext.API.Admin.Types
(
appPort
,
settings
,
Settings
)
import
Gargantext.API.Prelude
import
Gargantext.API.Routes.Named.Share
qualified
as
Named
import
Gargantext.Core.Config
(
gc_url
,
GargConfig
)
import
Gargantext.Core.Config
(
GargConfig
,
gc_frontend_config
)
import
Gargantext.Core.Config.Types
(
fc_url
)
import
Gargantext.Core.Types
(
NodeType
,
NodeId
,
unNodeId
,
_ValidationError
)
import
Gargantext.Database.Prelude
(
HasConfig
(
hasConfig
),
CmdCommon
)
import
Gargantext.Prelude
...
...
@@ -39,7 +40,7 @@ get_url :: Maybe NodeType
->
Settings
->
Either
String
Named
.
ShareLink
get_url
nt
id
gc
stgs
=
do
let
urlHost
=
T
.
unpack
$
gc
^.
gc_url
let
urlHost
=
T
.
unpack
$
gc
^.
gc_
frontend_config
.
fc_
url
let
urlPort
=
stgs
^.
appPort
t
<-
maybe
(
Left
"Invalid node Type"
)
Right
nt
i
<-
maybe
(
Left
"Invalid node ID"
)
Right
id
...
...
src/Gargantext/API/Routes.hs
View file @
8ce28ab3
...
...
@@ -31,10 +31,11 @@ import Gargantext.API.Node.Corpus.New qualified as New
import
Gargantext.API.Prelude
import
Gargantext.API.Routes.Named.Annuaire
qualified
as
Named
import
Gargantext.API.Routes.Named.Corpus
qualified
as
Named
import
Gargantext.Core.Config
(
gc_jobs
)
import
Gargantext.Core.Config.Types
(
jc_max_docs_scrapers
)
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Database.Prelude
(
HasConfig
(
..
))
import
Gargantext.Prelude
import
Gargantext.Core.Config
(
gc_max_docs_scrapers
)
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Servant
import
Servant.Auth.Swagger
()
...
...
@@ -55,7 +56,7 @@ waitAPI n = do
addCorpusWithQuery
::
User
->
Named
.
AddWithQuery
(
AsServerT
(
GargM
Env
BackendInternalError
))
addCorpusWithQuery
user
=
Named
.
AddWithQuery
$
\
cid
->
AsyncJobs
$
serveJobsAPI
AddCorpusQueryJob
$
\
jHandle
q
->
do
limit
<-
view
$
hasConfig
.
gc_max_docs_scrapers
limit
<-
view
$
hasConfig
.
gc_
jobs
.
jc_
max_docs_scrapers
New
.
addToCorpusWithQuery
user
cid
q
(
Just
$
fromIntegral
limit
)
jHandle
{- let log' x = do
printDebug "addToCorpusWithQuery" x
...
...
src/Gargantext/API/Server/Named.hs
View file @
8ce28ab3
...
...
@@ -18,14 +18,15 @@ import Gargantext.API.Auth.PolicyCheck ()
import
Gargantext.API.Errors
import
Gargantext.API.GraphQL
as
GraphQL
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.API.Server.Named.Public
(
serverPublicGargAPI
)
import
Gargantext.API.Routes.Named
import
Gargantext.API.Server.Named.Public
(
serverPublicGargAPI
)
import
Gargantext.API.Swagger
(
swaggerDoc
)
import
Gargantext.API.ThrowAll
(
serverPrivateGargAPI
)
import
Gargantext.Core.AsyncUpdates.Dispatcher.WebSocket
qualified
as
Dispatcher
import
Gargantext.Core.Config
(
gc_frontend_config
)
import
Gargantext.Core.Config.Types
(
fc_url_backend_api
)
import
Gargantext.Database.Prelude
(
hasConfig
)
import
Gargantext.Prelude
hiding
(
Handler
,
catch
)
import
Gargantext.Core.Config
(
gc_url_backend_api
)
import
Gargantext.System.Logging
(
logLocM
,
LogLevel
(
..
))
import
Paths_gargantext
qualified
as
PG
-- cabal magic build module
import
Servant
...
...
@@ -40,7 +41,7 @@ serverGargAPI env
,
gargForgotPasswordAsyncAPI
=
forgotPasswordAsync
,
gargVersionAPI
=
gargVersion
,
gargPrivateAPI
=
serverPrivateGargAPI
,
gargPublicAPI
=
serverPublicGargAPI
(
env
^.
hasConfig
.
gc_url_backend_api
)
,
gargPublicAPI
=
serverPublicGargAPI
(
env
^.
hasConfig
.
gc_
frontend_config
.
fc_
url_backend_api
)
}
where
gargVersion
::
GargVersion
(
AsServerT
(
GargM
Env
BackendInternalError
))
...
...
src/Gargantext/Core/Config.hs
View file @
8ce28ab3
...
...
@@ -18,24 +18,16 @@ module Gargantext.Core.Config (
GargConfig
(
..
)
-- * Lenses
,
gc_backend_name
,
gc_datafilepath
,
gc_epo_api_url
,
gc_js_id_timeout
,
gc_js_job_timeout
,
gc_masteruser
,
gc_max_docs_parsers
,
gc_max_docs_scrapers
,
gc_pubmed_api_key
,
gc_secretkey
,
gc_url
,
gc_url_backend_api
,
gc_frontend_config
,
gc_mail_config
,
gc_database_config
,
gc_nlp_config
,
gc_notifications_config
,
gc_frames
,
gc_jobs
,
gc_secrets
,
gc_apis
,
mkProxyUrl
)
where
...
...
@@ -54,32 +46,18 @@ import Toml.Schema
-- stripRight :: Char -> T.Text -> T.Text
-- stripRight c s = if T.last s == c then stripRight c (T.take (T.length s - 1) s) else s
data
GargConfig
=
GargConfig
{
_gc_backend_name
::
!
T
.
Text
,
_gc_url
::
!
T
.
Text
,
_gc_url_backend_api
::
!
T
.
Text
,
_gc_masteruser
::
!
T
.
Text
,
_gc_secretkey
::
!
T
.
Text
,
_gc_datafilepath
::
!
FilePath
data
GargConfig
=
GargConfig
{
_gc_datafilepath
::
!
FilePath
-- , _gc_repofilepath :: !FilePath
,
_gc_max_docs_parsers
::
!
Integer
,
_gc_max_docs_scrapers
::
!
Integer
,
_gc_js_job_timeout
::
!
Integer
,
_gc_js_id_timeout
::
!
Integer
,
_gc_pubmed_api_key
::
!
T
.
Text
,
_gc_epo_api_url
::
!
T
.
Text
,
_gc_frontend_config
::
!
FrontendConfig
,
_gc_mail_config
::
!
MailConfig
,
_gc_database_config
::
!
PSQL
.
ConnectInfo
,
_gc_nlp_config
::
!
NLPConfig
,
_gc_notifications_config
::
!
NotificationsConfig
,
_gc_frames
::
!
FramesConfig
,
_gc_jobs
::
!
JobsConfig
,
_gc_secrets
::
!
SecretsConfig
,
_gc_apis
::
!
APIsConfig
}
deriving
(
Generic
,
Show
)
...
...
@@ -87,62 +65,45 @@ makeLenses ''GargConfig
instance
FromValue
GargConfig
where
fromValue
=
parseTableFromValue
$
do
_gc_frontend_config
@
(
FrontendConfig
{
..
})
<-
reqKey
"frontend"
_gc_frontend_config
<-
reqKey
"frontend"
_gc_mail_config
<-
reqKey
"mail"
db_config
<-
reqKey
"database"
_gc_nlp_config
<-
reqKey
"nlp"
secrets
<-
reqKey
"secrets"
_gc_
secrets
<-
reqKey
"secrets"
_gc_datafilepath
<-
reqKeyOf
"paths"
$
parseTableFromValue
$
reqKey
"data_filepath"
_gc_frames
<-
reqKeyOf
"external"
$
parseTableFromValue
$
reqKey
"frames"
jobs
<-
reqKey
"jobs"
apis
<-
reqKey
"apis"
_gc_
jobs
<-
reqKey
"jobs"
_gc_
apis
<-
reqKey
"apis"
_gc_notifications_config
<-
reqKey
"notifications"
return
$
GargConfig
{
_gc_backend_name
=
_fc_backend_name
,
_gc_url
=
_fc_url
,
_gc_url_backend_api
=
_fc_url_backend_api
,
_gc_masteruser
=
_s_master_user
secrets
,
_gc_secretkey
=
_s_secret_key
secrets
,
_gc_datafilepath
,
_gc_max_docs_parsers
=
_jc_max_docs_parsers
jobs
,
_gc_max_docs_scrapers
=
_jc_max_docs_scrapers
jobs
,
_gc_js_job_timeout
=
_jc_js_job_timeout
jobs
,
_gc_js_id_timeout
=
_jc_js_id_timeout
jobs
,
_gc_pubmed_api_key
=
_ac_pubmed_api_key
apis
,
_gc_epo_api_url
=
_ac_epo_api_url
apis
return
$
GargConfig
{
_gc_datafilepath
,
_gc_jobs
,
_gc_apis
,
_gc_frontend_config
,
_gc_mail_config
,
_gc_database_config
=
unTOMLConnectInfo
db_config
,
_gc_nlp_config
,
_gc_notifications_config
,
_gc_frames
}
,
_gc_frames
,
_gc_secrets
}
instance
ToValue
GargConfig
where
toValue
=
defaultTableToValue
instance
ToTable
GargConfig
where
toTable
(
GargConfig
{
..
})
=
table
[
"frontend"
.=
_gc_frontend_config
,
"secrets"
.=
secrets
,
"secrets"
.=
_gc_
secrets
,
"paths"
.=
table
[
"data_filepath"
.=
_gc_datafilepath
]
,
"apis"
.=
apis
,
"apis"
.=
_gc_
apis
,
"external"
.=
table
[
"frames"
.=
_gc_frames
]
,
"jobs"
.=
jobs
,
"jobs"
.=
_gc_
jobs
,
"database"
.=
TOMLConnectInfo
_gc_database_config
,
"mail"
.=
_gc_mail_config
,
"notifications"
.=
_gc_notifications_config
,
"nlp"
.=
_gc_nlp_config
]
where
secrets
=
SecretsConfig
{
_s_master_user
=
_gc_masteruser
,
_s_secret_key
=
_gc_secretkey
}
apis
=
APIsConfig
{
_ac_pubmed_api_key
=
_gc_pubmed_api_key
,
_ac_epo_api_url
=
_gc_epo_api_url
}
jobs
=
JobsConfig
{
_jc_max_docs_parsers
=
_gc_max_docs_parsers
,
_jc_max_docs_scrapers
=
_gc_max_docs_scrapers
,
_jc_js_job_timeout
=
_gc_js_job_timeout
,
_jc_js_id_timeout
=
_gc_js_id_timeout
}
mkProxyUrl
::
GargConfig
->
MicroServicesSettings
->
BaseUrl
mkProxyUrl
GargConfig
{
..
}
MicroServicesSettings
{
..
}
=
case
parseBaseUrl
(
T
.
unpack
_gc_url
)
of
case
parseBaseUrl
(
T
.
unpack
$
_fc_url
_gc_frontend_config
)
of
Nothing
->
BaseUrl
Http
"localhost"
80
""
Just
bh
->
bh
{
baseUrlPort
=
_msProxyPort
}
src/Gargantext/Core/Config/Types.hs
View file @
8ce28ab3
...
...
@@ -14,23 +14,34 @@ TODO-SECURITY: Critical
{-# LANGUAGE ViewPatterns #-}
module
Gargantext.Core.Config.Types
(
SettingsFile
(
..
)
(
APIsConfig
(
..
)
,
ac_pubmed_api_key
,
ac_epo_api_url
,
CORSOrigin
(
..
)
,
CORSSettings
(
..
)
,
MicroServicesSettings
(
..
)
,
TOMLConnectInfo
(
..
)
,
FramesConfig
(
..
)
,
FrontendConfig
(
..
)
,
JobsConfig
(
..
)
,
APIsConfig
(
..
)
,
NotificationsConfig
(
..
)
,
SecretsConfig
(
..
)
,
f_write_url
,
f_calc_url
,
f_visio_url
,
f_searx_url
,
f_istex_url
,
FrontendConfig
(
..
)
,
fc_url
,
fc_backend_name
,
fc_url_backend_api
,
fc_jwt_settings
,
fc_cors
,
fc_microservices
,
JobsConfig
(
..
)
,
jc_max_docs_parsers
,
jc_max_docs_scrapers
,
jc_js_job_timeout
,
jc_js_id_timeout
,
MicroServicesSettings
(
..
)
,
NotificationsConfig
(
..
)
,
SecretsConfig
(
..
)
,
SettingsFile
(
..
)
,
TOMLConnectInfo
(
..
)
,
corsUseOriginsForHosts
,
corsAllowedOrigins
...
...
@@ -196,6 +207,8 @@ instance ToTable FrontendConfig where
,
"cors"
.=
_fc_cors
,
"microservices"
.=
_fc_microservices
]
makeLenses
''
F
rontendConfig
data
SecretsConfig
=
SecretsConfig
{
_s_master_user
::
!
Text
...
...
@@ -219,6 +232,7 @@ data JobsConfig =
,
_jc_max_docs_scrapers
::
!
Integer
,
_jc_js_job_timeout
::
!
Integer
,
_jc_js_id_timeout
::
!
Integer
}
deriving
(
Generic
,
Show
)
instance
FromValue
JobsConfig
where
fromValue
=
parseTableFromValue
$
do
_jc_max_docs_parsers
<-
reqKey
"max_docs_parsers"
...
...
@@ -234,10 +248,13 @@ instance ToTable JobsConfig where
,
"js_job_timeout"
.=
_jc_js_job_timeout
,
"js_id_timeout"
.=
_jc_js_id_timeout
]
makeLenses
''
J
obsConfig
data
APIsConfig
=
APIsConfig
{
_ac_pubmed_api_key
::
!
Text
,
_ac_epo_api_url
::
!
Text
}
deriving
(
Generic
,
Show
)
instance
FromValue
APIsConfig
where
fromValue
=
parseTableFromValue
$
do
_ac_pubmed_api_key
<-
reqKeyOf
"pubmed"
$
parseTableFromValue
$
reqKey
"api_key"
...
...
@@ -250,6 +267,8 @@ instance ToTable APIsConfig where
,
"epo"
.=
table
[
"api_url"
.=
_ac_epo_api_url
]
]
makeLenses
''
A
PIsConfig
data
NotificationsConfig
=
NotificationsConfig
{
_nc_central_exchange_bind
::
!
T
.
Text
...
...
src/Gargantext/Core/Mail.hs
View file @
8ce28ab3
...
...
@@ -15,12 +15,13 @@ import Control.Lens (view)
import
Control.Monad.Trans.Control
(
MonadBaseControl
)
import
Data.List
qualified
as
List
import
Data.Text
(
splitOn
)
import
Gargantext.Core.Config
(
gc_frontend_config
)
import
Gargantext.Core.Config.Types
(
fc_url
,
fc_backend_name
)
import
Gargantext.Core.Config.Mail
(
gargMail
,
GargMail
(
..
),
MailConfig
)
import
Gargantext.Core.Types.Individu
import
Gargantext.Database.Prelude
(
HasConfig
(
..
))
import
Gargantext.Database.Schema.User
(
UserLight
(
..
))
import
Gargantext.Prelude
import
Gargantext.Core.Config
(
gc_url
,
gc_backend_name
)
import
Gargantext.Core.Config.Mail
(
gargMail
,
GargMail
(
..
),
MailConfig
)
import
Network.URI.Encode
(
encodeText
)
...
...
@@ -74,7 +75,8 @@ mail mailCfg model = do
let
(
m
,
u
)
=
email_to
model
subject
=
email_subject
model
body
=
emailWith
(
ServerAddress
(
view
gc_backend_name
cfg
)
(
view
gc_url
cfg
))
model
body
=
emailWith
(
ServerAddress
(
view
(
gc_frontend_config
.
fc_backend_name
)
cfg
)
(
view
(
gc_frontend_config
.
fc_url
)
cfg
))
model
liftBase
$
gargMail
mailCfg
(
GargMail
{
gm_to
=
m
,
gm_name
=
Just
u
,
gm_subject
=
subject
...
...
src/Gargantext/Database/Action/Flow.hs
View file @
8ce28ab3
...
...
@@ -66,6 +66,8 @@ import EPO.API.Client.Types qualified as EPO
import
Gargantext.API.Ngrams.Tools
(
getTermsWith
)
import
Gargantext.Core
(
Lang
(
..
),
NLPServerConfig
,
withDefaultLanguage
)
import
Gargantext.Core.AsyncUpdates.CentralExchange.Types
(
HasCentralExchangeNotification
(
ce_notify
),
CEMessage
(
..
))
import
Gargantext.Core.Config
(
GargConfig
(
..
))
import
Gargantext.Core.Config.Types
(
APIsConfig
(
..
))
import
Gargantext.Core.Ext.IMTUser
(
readFile_Annuaire
)
import
Gargantext.Core.NLP
(
HasNLPServer
,
nlpServerGet
)
import
Gargantext.Core.NodeStory.Types
(
HasNodeStory
)
...
...
@@ -103,7 +105,6 @@ import Gargantext.Database.Query.Tree.Root (MkCorpusUser(..), getOrMkRoot, getOr
import
Gargantext.Database.Schema.Ngrams
(
indexNgrams
,
text2ngrams
)
import
Gargantext.Database.Schema.Node
(
node_hyperdata
)
import
Gargantext.Prelude
hiding
(
to
)
import
Gargantext.Core.Config
(
GargConfig
(
..
))
import
Gargantext.System.Logging
(
logLocM
,
LogLevel
(
DEBUG
),
MonadLogger
)
import
Gargantext.Utils.Jobs.Monad
(
JobHandle
,
MonadJobStatus
(
..
)
)
import
PUBMED.Types
qualified
as
PUBMED
...
...
@@ -138,7 +139,7 @@ getDataText :: (HasNodeError err, HasSettings env)
->
DBCmd'
env
err
(
Either
API
.
GetCorpusError
DataText
)
getDataText
(
ExternalOrigin
api
)
la
q
mPubmedAPIKey
mAuthKey
li
=
do
cfg
<-
view
hasConfig
eRes
<-
liftBase
$
API
.
get
api
(
_tt_lang
la
)
q
mPubmedAPIKey
mAuthKey
(
_
gc_epo_api_url
cfg
)
li
eRes
<-
liftBase
$
API
.
get
api
(
_tt_lang
la
)
q
mPubmedAPIKey
mAuthKey
(
_
ac_epo_api_url
$
_gc_apis
cfg
)
li
pure
$
DataNew
<$>
eRes
getDataText
(
InternalOrigin
_
)
la
q
_
_
_li
=
do
(
_masterUserId
,
_masterRootId
,
cId
)
<-
getOrMkRootWithCorpus
MkCorpusUserMaster
(
Nothing
::
Maybe
HyperdataCorpus
)
...
...
src/Gargantext/Database/Action/Node.hs
View file @
8ce28ab3
...
...
@@ -25,7 +25,7 @@ import Data.Text qualified as T
import
Gargantext.API.Admin.Types
(
settings
,
_microservicesSettings
,
HasSettings
)
import
Gargantext.Core
import
Gargantext.Core.Config
(
GargConfig
(
..
),
mkProxyUrl
)
import
Gargantext.Core.Config.Types
(
FramesConfig
(
..
),
MicroServicesSettings
(
..
))
import
Gargantext.Core.Config.Types
(
FramesConfig
(
..
),
MicroServicesSettings
(
..
)
,
SecretsConfig
(
..
)
)
import
Gargantext.Core.Types
(
Name
)
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Hyperdata.Default
...
...
@@ -127,7 +127,7 @@ mkNodeWithParent_ConfigureHyperdata' nt (Just i) uId name = do
NodeFrameVisio
->
pure
$
_f_visio_url
$
_gc_frames
cfg
_
->
nodeError
NeedsConfiguration
let
s
=
_
gc_secretkey
cfg
s
=
_
s_secret_key
$
_gc_secrets
cfg
hd
=
HyperdataFrame
u
(
hash
$
s
<>
(
show
nodeId
))
_
<-
updateHyperdata
nodeId
hd
pure
[
nodeId
]
...
...
Przemyslaw Kaminski
@cgenie
mentioned in commit
5660aec0
·
Oct 08, 2024
mentioned in commit
5660aec0
mentioned in commit 5660aec07ec5a0a0a5468f440092c1a8f57a864e
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment