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
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
59a5d04a
Commit
59a5d04a
authored
Dec 02, 2024
by
Grégoire Locqueville
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed `CmdCommon` -> `IsDBEnvExtra`
parent
c31df9dd
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
66 additions
and
66 deletions
+66
-66
Auth.hs
src/Gargantext/API/Admin/Auth.hs
+6
-6
GraphQL.hs
src/Gargantext/API/GraphQL.hs
+4
-4
Annuaire.hs
src/Gargantext/API/GraphQL/Annuaire.hs
+3
-3
Context.hs
src/Gargantext/API/GraphQL/Context.hs
+8
-8
Node.hs
src/Gargantext/API/GraphQL/Node.hs
+9
-9
Team.hs
src/Gargantext/API/GraphQL/Team.hs
+4
-4
TreeFirstLevel.hs
src/Gargantext/API/GraphQL/TreeFirstLevel.hs
+7
-7
User.hs
src/Gargantext/API/GraphQL/User.hs
+8
-8
UserInfo.hs
src/Gargantext/API/GraphQL/UserInfo.hs
+4
-4
ShareURL.hs
src/Gargantext/API/Node/ShareURL.hs
+2
-2
Delete.hs
src/Gargantext/Database/Action/Delete.hs
+2
-2
Prelude.hs
src/Gargantext/Database/Prelude.hs
+9
-9
No files found.
src/Gargantext/API/Admin/Auth.hs
View file @
59a5d04a
...
...
@@ -62,7 +62,7 @@ import Gargantext.Core.Types.Individu (User(..), Username, GargPassword(..))
import
Gargantext.Core.Worker.Jobs.Types
qualified
as
Jobs
import
Gargantext.Database.Action.User.New
(
guessUserName
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
(
..
),
UserId
)
import
Gargantext.Database.Prelude
(
Cmd
'
,
CmdCommon
,
DbCmd
'
)
import
Gargantext.Database.Prelude
(
Cmd
'
,
IsDBEnvExtra
,
DbCmd
'
)
import
Gargantext.Database.Query.Table.User
import
Gargantext.Database.Query.Tree
(
isDescendantOf
,
isIn
)
import
Gargantext.Database.Query.Tree.Root
(
getRoot
)
...
...
@@ -235,12 +235,12 @@ forgotPassword = Named.ForgotPasswordAPI
,
forgotPasswordGetEp
=
forgotPasswordGet
}
forgotPasswordPost
::
(
CmdCommon
env
)
forgotPasswordPost
::
(
IsDBEnvExtra
env
)
=>
ForgotPasswordRequest
->
Cmd'
env
err
ForgotPasswordResponse
forgotPasswordPost
(
ForgotPasswordRequest
_email
)
=
do
pure
$
ForgotPasswordResponse
"ok"
forgotPasswordGet
::
(
CmdCommon
env
,
HasServerError
err
)
forgotPasswordGet
::
(
IsDBEnvExtra
env
,
HasServerError
err
)
=>
Maybe
Text
->
Cmd'
env
err
ForgotPasswordGet
forgotPasswordGet
Nothing
=
pure
$
ForgotPasswordGet
""
forgotPasswordGet
(
Just
uuid
)
=
do
...
...
@@ -257,7 +257,7 @@ forgotPasswordGet (Just uuid) = do
---------------------
forgotPasswordGetUser
::
(
CmdCommon
env
)
forgotPasswordGetUser
::
(
IsDBEnvExtra
env
)
=>
UserLight
->
Cmd'
env
err
ForgotPasswordGet
forgotPasswordGetUser
(
UserLight
{
..
})
=
do
-- pick some random password
...
...
@@ -276,7 +276,7 @@ forgotPasswordGetUser (UserLight { .. }) = do
pure
$
ForgotPasswordGet
password
forgotUserPassword
::
(
CmdCommon
env
)
forgotUserPassword
::
(
IsDBEnvExtra
env
)
=>
UserLight
->
Cmd'
env
err
()
forgotUserPassword
(
UserLight
{
..
})
=
do
--printDebug "[forgotUserPassword] userLight_id" userLight_id
...
...
@@ -301,7 +301,7 @@ forgotUserPassword (UserLight { .. }) = do
--------------------------
-- Generate a unique (in whole DB) UUID for passwords.
generateForgotPasswordUUID
::
(
CmdCommon
env
)
generateForgotPasswordUUID
::
(
IsDBEnvExtra
env
)
=>
Cmd'
env
err
UUID
generateForgotPasswordUUID
=
do
uuid
<-
liftBase
$
nextRandom
...
...
src/Gargantext/API/GraphQL.hs
View file @
59a5d04a
...
...
@@ -42,7 +42,7 @@ import Gargantext.API.Prelude (GargM)
import
Gargantext.API.Types
(
HTML
)
import
Gargantext.Core.Config
(
HasJWTSettings
)
import
Gargantext.Core.NLP
(
HasNLPServer
)
import
Gargantext.Database.Prelude
(
CmdCommon
)
import
Gargantext.Database.Prelude
(
IsDBEnvExtra
)
import
Gargantext.Prelude
hiding
(
ByteString
)
import
Servant
import
Servant.Auth
qualified
as
SA
...
...
@@ -98,7 +98,7 @@ data Contet m
-- | The main GraphQL resolver: how queries, mutations and
-- subscriptions are handled.
rootResolver
::
(
CmdCommon
env
,
HasNLPServer
env
,
HasJWTSettings
env
)
::
(
IsDBEnvExtra
env
,
HasNLPServer
env
,
HasJWTSettings
env
)
=>
AuthenticatedUser
->
AccessPolicyManager
->
RootResolver
(
GargM
env
BackendInternalError
)
e
Query
Mutation
Undefined
...
...
@@ -129,7 +129,7 @@ rootResolver authenticatedUser policyManager =
-- | Main GraphQL "app".
app
::
(
Typeable
env
,
CmdCommon
env
,
HasNLPServer
env
,
HasJWTSettings
env
)
::
(
Typeable
env
,
IsDBEnvExtra
env
,
HasNLPServer
env
,
HasJWTSettings
env
)
=>
AuthenticatedUser
->
AccessPolicyManager
->
App
(
EVENT
(
GargM
env
BackendInternalError
))
(
GargM
env
BackendInternalError
)
...
...
@@ -167,7 +167,7 @@ data GraphQLAPIEndpoints mode = GraphQLAPIEndpoints
-- | Implementation of our API.
api
::
(
Typeable
env
,
CmdCommon
env
,
HasJWTSettings
env
)
::
(
Typeable
env
,
IsDBEnvExtra
env
,
HasJWTSettings
env
)
=>
GraphQLAPI
(
AsServerT
(
GargM
env
BackendInternalError
))
api
=
GraphQLAPI
$
\
case
(
SAS
.
Authenticated
auser
)
...
...
src/Gargantext/API/GraphQL/Annuaire.hs
View file @
59a5d04a
...
...
@@ -23,7 +23,7 @@ import Gargantext.Database.Admin.Types.Hyperdata.Contact
,
cw_lastName
,
hc_who
,
ContactWhere
,
hc_where
,
cw_organization
,
cw_labTeamDepts
,
cw_role
,
cw_office
,
cw_country
,
cw_city
,
cw_touch
,
ct_mail
,
ct_phone
,
ct_url
,
hc_title
,
hc_source
)
import
Gargantext.Database.Admin.Types.Node
(
ContextId
(
..
))
import
Gargantext.Database.Prelude
(
CmdCommon
)
import
Gargantext.Database.Prelude
(
IsDBEnvExtra
)
import
Gargantext.Database.Query.Table.Context
(
getContextWith
)
import
Gargantext.Database.Schema.Node
(
node_hyperdata
)
import
Gargantext.Prelude
...
...
@@ -55,13 +55,13 @@ data AnnuaireContactArgs
-- | Function to resolve user from a query.
resolveAnnuaireContacts
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
AnnuaireContactArgs
->
GqlM
e
env
[
AnnuaireContact
]
resolveAnnuaireContacts
AnnuaireContactArgs
{
contact_id
}
=
dbAnnuaireContacts
contact_id
-- | Inner function to fetch the user from DB.
dbAnnuaireContacts
::
CmdCommon
env
::
IsDBEnvExtra
env
=>
Int
->
GqlM
e
env
[
AnnuaireContact
]
dbAnnuaireContacts
contact_id
=
do
-- lift $ printDebug "[dbUsers]" user_id
...
...
src/Gargantext/API/GraphQL/Context.hs
View file @
59a5d04a
...
...
@@ -33,7 +33,7 @@ import Gargantext.API.Prelude (GargM)
import
Gargantext.Core.Types.Search
(
HyperdataRow
(
..
),
toHyperdataRow
)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
HyperdataDocument
)
import
Gargantext.Database.Admin.Types.Node
(
ContextTitle
,
NodeId
(
..
),
NodeTypeId
,
UserId
,
unNodeId
,
ContextId
(
..
))
import
Gargantext.Database.Prelude
(
CmdCommon
)
import
Gargantext.Database.Prelude
(
IsDBEnvExtra
)
import
Gargantext.Database.Query.Table.NodeContext
(
getNodeContext
,
getContextsForNgramsTerms
,
ContextForNgramsTerms
(
..
),
{- getContextNgrams, -}
getContextNgramsMatchingFTS
)
import
Gargantext.Database.Query.Table.NodeContext
qualified
as
DNC
import
Gargantext.Database.Schema.NodeContext
(
NodeContext
,
NodeContextPoly
(
..
))
...
...
@@ -119,19 +119,19 @@ type GqlM' e env a = ResolverM e (GargM env BackendInternalError) a
-- | Function to resolve context from a query.
resolveNodeContext
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
NodeContextArgs
->
GqlM
e
env
[
NodeContextGQL
]
resolveNodeContext
NodeContextArgs
{
context_id
,
node_id
}
=
dbNodeContext
context_id
node_id
resolveContextsForNgrams
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
ContextsForNgramsArgs
->
GqlM
e
env
[
ContextGQL
]
resolveContextsForNgrams
ContextsForNgramsArgs
{
corpus_id
,
ngrams_terms
,
and_logic
}
=
dbContextForNgrams
corpus_id
ngrams_terms
and_logic
resolveContextNgrams
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
ContextNgramsArgs
->
GqlM
e
env
[
Text
]
resolveContextNgrams
ContextNgramsArgs
{
context_id
,
list_id
}
=
dbContextNgrams
context_id
list_id
...
...
@@ -140,7 +140,7 @@ resolveContextNgrams ContextNgramsArgs { context_id, list_id } =
-- | Inner function to fetch the node context DB.
dbNodeContext
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
Int
->
Int
->
GqlM
e
env
[
NodeContextGQL
]
dbNodeContext
context_id
node_id
=
do
-- lift $ printDebug "[dbUsers]" user_id
...
...
@@ -152,7 +152,7 @@ dbNodeContext context_id node_id = do
-- | Returns list of `ContextGQL` for given ngrams in given corpus id.
dbContextForNgrams
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
Int
->
[
Text
]
->
Text
->
GqlM
e
env
[
ContextGQL
]
dbContextForNgrams
node_id
ngrams_terms
and_logic
=
do
contextsForNgramsTerms
<-
lift
$
getContextsForNgramsTerms
(
UnsafeMkNodeId
node_id
)
ngrams_terms
(
readMaybe
$
unpack
$
Text
.
toTitle
and_logic
)
...
...
@@ -161,7 +161,7 @@ dbContextForNgrams node_id ngrams_terms and_logic = do
-- | Fetch ngrams matching given context in a given list id.
dbContextNgrams
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
Int
->
Int
->
GqlM
e
env
[
Text
]
dbContextNgrams
context_id
list_id
=
do
lift
$
getContextNgramsMatchingFTS
(
UnsafeMkContextId
context_id
)
(
UnsafeMkNodeId
list_id
)
...
...
@@ -221,7 +221,7 @@ toHyperdataRowDocumentGQL hyperdata =
}
HyperdataRowContact
{
}
->
Nothing
updateNodeContextCategory
::
(
CmdCommon
env
)
updateNodeContextCategory
::
(
IsDBEnvExtra
env
)
=>
AuthenticatedUser
->
AccessPolicyManager
->
NodeContextCategoryMArgs
...
...
src/Gargantext/API/GraphQL/Node.hs
View file @
59a5d04a
...
...
@@ -24,7 +24,7 @@ import Gargantext.API.GraphQL.Types ( GqlM )
import
Gargantext.Core
(
HasDBid
(
lookupDBid
)
)
import
Gargantext.Database.Admin.Types.Node
(
NodeType
)
import
Gargantext.Database.Admin.Types.Node
qualified
as
NN
import
Gargantext.Database.Prelude
(
CmdCommon
)
-- , JSONB)
import
Gargantext.Database.Prelude
(
IsDBEnvExtra
)
-- , JSONB)
import
Gargantext.Database.Query.Table.Node
(
getClosestChildrenByType
,
getClosestParentIdByType
,
getNode
)
import
Gargantext.Database.Schema.Node
qualified
as
N
import
Gargantext.Prelude
...
...
@@ -57,7 +57,7 @@ data NodeArgs
-- | Function to resolve user from a query.
resolveNodes
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
AuthenticatedUser
->
AccessPolicyManager
->
NodeArgs
...
...
@@ -66,19 +66,19 @@ resolveNodes autUser mgr NodeArgs { node_id } =
withPolicy
autUser
mgr
(
nodeReadChecks
$
NN
.
UnsafeMkNodeId
node_id
)
$
dbNodes
node_id
resolveNodesCorpus
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
CorpusArgs
->
GqlM
e
env
[
Corpus
]
resolveNodesCorpus
CorpusArgs
{
corpus_id
}
=
dbNodesCorpus
corpus_id
dbNodes
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
Int
->
GqlM
e
env
[
Node
]
dbNodes
node_id
=
do
node
<-
lift
$
getNode
$
NN
.
UnsafeMkNodeId
node_id
pure
[
toNode
node
]
dbNodesCorpus
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
Int
->
GqlM
e
env
[
Corpus
]
dbNodesCorpus
corpus_id
=
do
corpus
<-
lift
$
getNode
$
NN
.
UnsafeMkNodeId
corpus_id
...
...
@@ -97,17 +97,17 @@ data NodeChildrenArgs
}
deriving
(
Generic
,
GQLType
)
resolveNodeParent
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
NodeParentArgs
->
GqlM
e
env
[
Node
]
resolveNodeParent
NodeParentArgs
{
node_id
,
parent_type
}
=
dbParentNodes
node_id
parent_type
resolveNodeChildren
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
NodeChildrenArgs
->
GqlM
e
env
[
Node
]
resolveNodeChildren
NodeChildrenArgs
{
node_id
,
child_type
}
=
dbChildNodes
node_id
child_type
dbParentNodes
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
Int
->
NodeType
->
GqlM
e
env
[
Node
]
dbParentNodes
node_id
parentType
=
do
-- let mParentType = readEither (T.unpack parent_type) :: Either Prelude.String NodeType
...
...
@@ -123,7 +123,7 @@ dbParentNodes node_id parentType = do
node
<-
lift
$
getNode
id
pure
[
toNode
node
]
dbChildNodes
::
(
CmdCommon
env
)
dbChildNodes
::
(
IsDBEnvExtra
env
)
=>
Int
->
NodeType
->
GqlM
e
env
[
Node
]
dbChildNodes
node_id
childType
=
do
childIds
<-
lift
$
getClosestChildrenByType
(
NN
.
UnsafeMkNodeId
node_id
)
childType
-- (fromNodeTypeId parent_type_id)
...
...
src/Gargantext/API/GraphQL/Team.hs
View file @
59a5d04a
...
...
@@ -25,7 +25,7 @@ import Gargantext.Core.Config (HasJWTSettings)
import
Gargantext.Core.Types
(
NodeId
(
..
),
unNodeId
)
import
Gargantext.Core.Types.Individu
qualified
as
Individu
import
Gargantext.Database.Action.Share
(
membersOf
,
deleteMemberShip
)
import
Gargantext.Database.Prelude
(
CmdCommon
)
import
Gargantext.Database.Prelude
(
IsDBEnvExtra
)
import
Gargantext.Database.Query.Table.Node
(
getNode
)
import
Gargantext.Database.Query.Table.User
(
getUsersWithNodeHyperdata
)
import
Gargantext.Database.Schema.Node
(
NodePoly
(
Node
,
_node_id
),
_node_user_id
)
...
...
@@ -53,10 +53,10 @@ data TeamDeleteMArgs = TeamDeleteMArgs
type
GqlM'
e
env
a
=
ResolverM
e
(
GargM
env
BackendInternalError
)
a
resolveTeam
::
(
CmdCommon
env
)
=>
TeamArgs
->
GqlM
e
env
Team
resolveTeam
::
(
IsDBEnvExtra
env
)
=>
TeamArgs
->
GqlM
e
env
Team
resolveTeam
TeamArgs
{
team_node_id
}
=
dbTeam
team_node_id
dbTeam
::
(
CmdCommon
env
)
=>
dbTeam
::
(
IsDBEnvExtra
env
)
=>
Int
->
GqlM
e
env
Team
dbTeam
nodeId
=
do
let
nId
=
UnsafeMkNodeId
nodeId
...
...
@@ -78,7 +78,7 @@ dbTeam nodeId = do
getUsername
((
UserLight
{
userLight_username
},
_
)
:
_
)
=
userLight_username
-- TODO: list as argument
deleteTeamMembership
::
(
CmdCommon
env
,
HasJWTSettings
env
)
=>
deleteTeamMembership
::
(
IsDBEnvExtra
env
,
HasJWTSettings
env
)
=>
TeamDeleteMArgs
->
GqlM'
e
env
[
Int
]
deleteTeamMembership
TeamDeleteMArgs
{
token
,
shared_folder_id
,
team_node_id
}
=
do
teamNode
<-
lift
$
getNode
$
UnsafeMkNodeId
team_node_id
...
...
src/Gargantext/API/GraphQL/TreeFirstLevel.hs
View file @
59a5d04a
...
...
@@ -25,7 +25,7 @@ import Gargantext.Core.Types.Main ( Tree(..), _tn_node, _tn_children, NodeTree(.
import
Gargantext.Database.Admin.Config
()
import
Gargantext.Database.Admin.Types.Node
(
allNodeTypes
,
NodeId
(
..
),
NodeType
)
import
Gargantext.Database.Admin.Types.Node
qualified
as
NN
import
Gargantext.Database.Prelude
(
CmdCommon
)
import
Gargantext.Database.Prelude
(
IsDBEnvExtra
)
import
Gargantext.Database.Query.Table.Node
(
getNode
)
import
Gargantext.Database.Query.Tree
qualified
as
T
import
Gargantext.Database.Schema.Node
(
NodePoly
(
_node_parent_id
))
...
...
@@ -65,7 +65,7 @@ data BreadcrumbInfo = BreadcrumbInfo
type
ParentId
=
Maybe
NodeId
resolveTree
::
(
CmdCommon
env
)
resolveTree
::
(
IsDBEnvExtra
env
)
=>
AuthenticatedUser
->
AccessPolicyManager
->
TreeArgs
...
...
@@ -73,7 +73,7 @@ resolveTree :: (CmdCommon env)
resolveTree
autUser
mgr
TreeArgs
{
root_id
}
=
withPolicy
autUser
mgr
(
nodeReadChecks
$
UnsafeMkNodeId
root_id
)
$
dbTree
(
_auth_user_id
autUser
)
root_id
dbTree
::
(
CmdCommon
env
)
=>
dbTree
::
(
IsDBEnvExtra
env
)
=>
NN
.
UserId
->
Int
->
GqlM
e
env
(
TreeFirstLevel
(
GqlM
e
env
))
dbTree
loggedInUserId
root_id
=
do
let
rId
=
UnsafeMkNodeId
root_id
...
...
@@ -85,7 +85,7 @@ dbTree loggedInUserId root_id = do
toParentId
N
.
Node
{
_node_parent_id
}
=
_node_parent_id
toTree
::
(
CmdCommon
env
)
=>
NodeId
->
ParentId
->
Tree
NodeTree
->
TreeFirstLevel
(
GqlM
e
env
)
toTree
::
(
IsDBEnvExtra
env
)
=>
NodeId
->
ParentId
->
Tree
NodeTree
->
TreeFirstLevel
(
GqlM
e
env
)
toTree
rId
pId
TreeN
{
_tn_node
,
_tn_children
}
=
TreeFirstLevel
{
parent
=
resolveParent
pId
,
root
=
toTreeNode
pId
_tn_node
...
...
@@ -98,7 +98,7 @@ toTreeNode pId NodeTree { _nt_name, _nt_id, _nt_type } = TreeNode { name = _nt_n
childrenToTreeNodes
::
(
Tree
NodeTree
,
NodeId
)
->
TreeNode
childrenToTreeNodes
(
TreeN
{
_tn_node
},
rId
)
=
toTreeNode
(
Just
rId
)
_tn_node
resolveParent
::
(
CmdCommon
env
)
=>
Maybe
NodeId
->
GqlM
e
env
(
Maybe
TreeNode
)
resolveParent
::
(
IsDBEnvExtra
env
)
=>
Maybe
NodeId
->
GqlM
e
env
(
Maybe
TreeNode
)
resolveParent
(
Just
pId
)
=
do
node
<-
lift
$
getNode
pId
pure
$
nodeToTreeNode
node
...
...
@@ -117,7 +117,7 @@ nodeToTreeNode N.Node {..} =
else
Nothing
resolveBreadcrumb
::
(
CmdCommon
env
)
=>
BreadcrumbArgs
->
GqlM
e
env
BreadcrumbInfo
resolveBreadcrumb
::
(
IsDBEnvExtra
env
)
=>
BreadcrumbArgs
->
GqlM
e
env
BreadcrumbInfo
resolveBreadcrumb
BreadcrumbArgs
{
node_id
}
=
dbRecursiveParents
node_id
convertDbTreeToTreeNode
::
HasCallStack
=>
T
.
DbTreeNode
->
TreeNode
...
...
@@ -130,7 +130,7 @@ convertDbTreeToTreeNode T.DbTreeNode { _dt_name, _dt_nodeId, _dt_typeId, _dt_par
}
dbRecursiveParents
::
(
CmdCommon
env
)
=>
Int
->
GqlM
e
env
BreadcrumbInfo
dbRecursiveParents
::
(
IsDBEnvExtra
env
)
=>
Int
->
GqlM
e
env
BreadcrumbInfo
dbRecursiveParents
nodeId
=
do
let
nId
=
UnsafeMkNodeId
nodeId
dbParents
<-
lift
$
T
.
recursiveParents
nId
allNodeTypes
...
...
src/Gargantext/API/GraphQL/User.hs
View file @
59a5d04a
...
...
@@ -22,7 +22,7 @@ import Gargantext.API.GraphQL.Types (GqlM, GqlM')
import
Gargantext.Core.Types
(
NodeId
(
..
),
UserId
)
import
Gargantext.Core.Types.Individu
qualified
as
Individu
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataUser
(
..
))
import
Gargantext.Database.Prelude
(
CmdCommon
)
import
Gargantext.Database.Prelude
(
IsDBEnvExtra
)
import
Gargantext.Database.Query.Table.User
qualified
as
DBUser
import
Gargantext.Database.Schema.User
(
UserLight
(
..
))
import
Gargantext.Prelude
...
...
@@ -60,7 +60,7 @@ data UserEPOAPITokenMArgs
-- | Function to resolve user from a query.
resolveUsers
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
AuthenticatedUser
->
AccessPolicyManager
->
UserArgs
...
...
@@ -70,12 +70,12 @@ resolveUsers autUser mgr UserArgs { user_id } = do
withPolicy
autUser
mgr
(
nodeReadChecks
$
UnsafeMkNodeId
user_id
)
$
dbUsers
user_id
-- | Inner function to fetch the user from DB.
dbUsers
::
(
CmdCommon
env
)
dbUsers
::
(
IsDBEnvExtra
env
)
=>
Int
->
GqlM
e
env
[
User
(
GqlM
e
env
)]
dbUsers
user_id
=
lift
(
map
toUser
<$>
DBUser
.
getUsersWithId
(
Individu
.
RootId
$
UnsafeMkNodeId
user_id
))
toUser
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
UserLight
->
User
(
GqlM
e
env
)
toUser
(
UserLight
{
..
})
=
User
{
u_email
=
userLight_email
,
u_hyperdata
=
resolveHyperdata
userLight_id
...
...
@@ -83,25 +83,25 @@ toUser (UserLight { .. }) = User { u_email = userLight_email
,
u_username
=
userLight_username
}
resolveHyperdata
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
UserId
->
GqlM
e
env
(
Maybe
HyperdataUser
)
resolveHyperdata
userid
=
lift
(
listToMaybe
<$>
DBUser
.
getUserHyperdata
(
Individu
.
UserDBId
userid
))
updateUserPubmedAPIKey
::
(
CmdCommon
env
)
=>
updateUserPubmedAPIKey
::
(
IsDBEnvExtra
env
)
=>
UserPubmedAPIKeyMArgs
->
GqlM'
e
env
Int
updateUserPubmedAPIKey
UserPubmedAPIKeyMArgs
{
user_id
,
api_key
}
=
do
_
<-
lift
$
DBUser
.
updateUserPubmedAPIKey
(
Individu
.
RootId
$
UnsafeMkNodeId
user_id
)
api_key
pure
1
updateUserEPOAPIUser
::
(
CmdCommon
env
)
=>
updateUserEPOAPIUser
::
(
IsDBEnvExtra
env
)
=>
UserEPOAPIUserMArgs
->
GqlM'
e
env
Int
updateUserEPOAPIUser
UserEPOAPIUserMArgs
{
user_id
,
api_user
}
=
do
_
<-
lift
$
DBUser
.
updateUserEPOAPIUser
(
Individu
.
RootId
$
UnsafeMkNodeId
user_id
)
api_user
pure
1
updateUserEPOAPIToken
::
(
CmdCommon
env
)
=>
updateUserEPOAPIToken
::
(
IsDBEnvExtra
env
)
=>
UserEPOAPITokenMArgs
->
GqlM'
e
env
Int
updateUserEPOAPIToken
UserEPOAPITokenMArgs
{
user_id
,
api_token
}
=
do
_
<-
lift
$
DBUser
.
updateUserEPOAPIToken
(
Individu
.
RootId
$
UnsafeMkNodeId
user_id
)
api_token
...
...
src/Gargantext/API/GraphQL/UserInfo.hs
View file @
59a5d04a
...
...
@@ -49,7 +49,7 @@ import Gargantext.API.GraphQL.Utils (AuthStatus(Invalid, Valid), authUser)
import
Gargantext.Core.Config
(
HasJWTSettings
)
import
Gargantext.Core.Types
(
UserId
(
..
))
import
Gargantext.Core.Types.Individu
qualified
as
Individu
import
Gargantext.Database.Prelude
(
CmdCommon
)
import
Gargantext.Database.Prelude
(
IsDBEnvExtra
)
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Query.Table.User
(
getUsersWithHyperdata
,
getUsersWithNodeHyperdata
,
updateUserEmail
)
import
Gargantext.Database.Schema.Node
(
node_id
,
node_hyperdata
,
NodePoly
(
Node
,
_node_id
))
...
...
@@ -108,7 +108,7 @@ data UserInfoMArgs
-- | Function to resolve user from a query.
resolveUserInfos
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
AuthenticatedUser
->
AccessPolicyManager
->
UserInfoArgs
->
GqlM
e
env
[
UserInfo
]
...
...
@@ -118,7 +118,7 @@ resolveUserInfos autUser mgr UserInfoArgs { user_id } =
-- | Mutation for user info
updateUserInfo
::
(
CmdCommon
env
,
HasJWTSettings
env
)
::
(
IsDBEnvExtra
env
,
HasJWTSettings
env
)
-- => UserInfoMArgs -> ResolverM e (GargM env err) Int
=>
UserInfoMArgs
->
GqlM'
e
env
Int
updateUserInfo
(
UserInfoMArgs
{
ui_id
,
..
})
=
do
...
...
@@ -167,7 +167,7 @@ updateUserInfo (UserInfoMArgs { ui_id, .. }) = do
-- | Inner function to fetch the user from DB.
dbUsers
::
(
CmdCommon
env
)
::
(
IsDBEnvExtra
env
)
=>
UserId
->
GqlM
e
env
[
UserInfo
]
dbUsers
user_id
=
do
-- lift $ printDebug "[dbUsers]" user_id
...
...
src/Gargantext/API/Node/ShareURL.hs
View file @
59a5d04a
...
...
@@ -12,7 +12,7 @@ import Gargantext.API.Routes.Named.Share qualified as Named
import
Gargantext.Core.Config
(
GargConfig
,
gc_frontend_config
,
HasConfig
(
hasConfig
))
import
Gargantext.Core.Config.Types
(
fc_appPort
,
fc_url
)
import
Gargantext.Core.Types
(
NodeType
,
NodeId
,
unNodeId
,
_ValidationError
)
import
Gargantext.Database.Prelude
(
CmdCommon
)
import
Gargantext.Database.Prelude
(
IsDBEnvExtra
)
import
Gargantext.Prelude
import
Network.URI
(
parseURI
)
import
Prelude
(
String
)
...
...
@@ -21,7 +21,7 @@ import Servant.Server.Generic (AsServerT)
shareURL
::
IsGargServer
env
err
m
=>
Named
.
ShareURL
(
AsServerT
m
)
shareURL
=
Named
.
ShareURL
getUrl
getUrl
::
(
IsGargServer
env
err
m
,
CmdCommon
env
)
getUrl
::
(
IsGargServer
env
err
m
,
IsDBEnvExtra
env
)
=>
Maybe
NodeType
->
Maybe
NodeId
->
m
Named
.
ShareLink
...
...
src/Gargantext/Database/Action/Delete.hs
View file @
59a5d04a
...
...
@@ -27,7 +27,7 @@ import Gargantext.Database.Action.User (getUserId)
import
Gargantext.Database.Admin.Types.Hyperdata.File
(
HyperdataFile
(
..
)
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
,
NodeType
(
..
)
)
-- (NodeType(..))
import
Gargantext.Database.GargDB
qualified
as
GargDB
import
Gargantext.Database.Prelude
(
Cmd
'
,
CmdCommon
)
import
Gargantext.Database.Prelude
(
Cmd
'
,
IsDBEnvExtra
)
import
Gargantext.Database.Query.Table.Node
(
getNodeWith
)
import
Gargantext.Database.Query.Table.Node
qualified
as
N
(
getNode
,
deleteNode
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
)
...
...
@@ -38,7 +38,7 @@ import Gargantext.Prelude
-- TODO
-- Delete Corpus children accoring its types
-- Delete NodeList (NodeStory + cbor file)
deleteNode
::
(
CmdCommon
env
,
HasNodeError
err
)
deleteNode
::
(
IsDBEnvExtra
env
,
HasNodeError
err
)
=>
User
->
NodeId
->
Cmd'
env
err
Int
...
...
src/Gargantext/Database/Prelude.hs
View file @
59a5d04a
...
...
@@ -74,21 +74,21 @@ type IsDBEnv env =
,
HasConfig
env
)
type
CmdCommon
env
=
(
IsDBEnv
env
,
Has
Config
env
,
Has
Mail
env
,
HasNLPServer
env
,
CET
.
HasCentralExchangeNotification
env
)
type
IsDBEnvExtra
env
=
(
IsDBEnv
env
,
Has
Mail
env
,
Has
NLPServer
env
,
CET
.
HasCentralExchangeNotification
env
)
type
CmdM
env
err
m
=
(
CmdM'
env
err
m
,
CmdCommon
env
(
CmdM'
env
err
m
,
IsDBEnvExtra
env
)
type
CmdRandom
env
err
m
=
(
CmdM'
env
err
m
,
IsDBEnv
env
,
IsDBEnv
env
,
MonadRandom
m
,
HasMail
env
)
...
...
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