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
159
Issues
159
List
Board
Labels
Milestones
Merge Requests
8
Merge Requests
8
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
4327e2a6
Commit
4327e2a6
authored
Nov 14, 2024
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/adinapoli/issue-400-fix-public-root-lookup' into dev-merge
parents
e8dd9c1b
59d96471
Pipeline
#6971
passed with stages
in 54 minutes and 42 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
Node.hs
src/Gargantext/Database/Query/Table/Node.hs
+9
-4
PublishNode.hs
test/Test/Database/Operations/PublishNode.hs
+6
-4
No files found.
src/Gargantext/Database/Query/Table/Node.hs
View file @
4327e2a6
...
...
@@ -81,6 +81,7 @@ import Gargantext.Database.Schema.Node
import
Gargantext.Prelude
hiding
(
sum
,
head
)
import
Opaleye
hiding
(
FromField
)
import
Prelude
hiding
(
null
,
id
,
map
,
sum
)
import
qualified
Data.List.NonEmpty
as
NE
queryNodeSearchTable
::
Select
NodeSearchRead
...
...
@@ -448,10 +449,14 @@ get_user_root_node_folder nty userId = do
where_
$
(
n
^.
node_typename
.==
sqlInt4
(
toDBid
nty
))
.&&
(
n
^.
node_user_id
.==
sqlInt4
(
_UserId
userId
))
pure
n
case
result
of
[]
->
nodeError
$
NodeLookupFailed
$
UserFolderDoesNotExist
userId
[
n
]
->
pure
n
folders
->
nodeError
$
NodeLookupFailed
$
UserHasTooManyRoots
userId
(
map
_node_id
folders
)
case
NE
.
nonEmpty
result
of
Nothing
->
nodeError
$
NodeLookupFailed
$
UserFolderDoesNotExist
userId
-- See https://gitlab.iscpif.fr/gargantext/haskell-gargantext/merge_requests/350#note_12732
-- User might have more than one public folder, in which case we need to take the one with the
-- smallest id.
Just
folders
->
pure
$
NE
.
head
(
NE
.
sortWith
_node_id
folders
)
-- | An input 'NodeId' identifies a user node if its typename is 'NodeUser' and it has no parent_id.
isUserNode
::
HasDBid
NodeType
=>
NodeId
->
DBCmd
err
Bool
...
...
test/Test/Database/Operations/PublishNode.hs
View file @
4327e2a6
...
...
@@ -16,7 +16,6 @@ module Test.Database.Operations.PublishNode where
import
Prelude
import
Control.Monad.Reader
import
Gargantext.Core
import
Gargantext.Core.Types.Individu
import
Gargantext.Database.Action.User
(
getUserId
)
import
Gargantext.Database.Admin.Types.Node
...
...
@@ -35,12 +34,15 @@ publishStrict = publishNode NPP_publish_no_edits_allowed
publishLenient
::
SourceId
->
TargetId
->
DBCmd
err
()
publishLenient
=
publishNode
NPP_publish_edits_only_owner_or_super
-- Also test that in the presence of /multiple/ public folders, we take the
-- first one (i.e. the \"root\" one).
testGetUserRootPublicNode
::
TestEnv
->
Assertion
testGetUserRootPublicNode
testEnv
=
do
[
aliceId
,
_bobId
]
<-
createAliceAndBob
testEnv
alicePublicFolder
<-
flip
runReaderT
testEnv
$
runTestMonad
$
do
getUserRootPublicNode
aliceId
_node_typename
alicePublicFolder
@?=
(
toDBid
NodeFolderPublic
)
publicFolder2
<-
newPublicFolderForUser
testEnv
"alice"
flip
runReaderT
testEnv
$
runTestMonad
$
do
rootPublicFolder
<-
getUserRootPublicNode
aliceId
liftIO
$
assertBool
"wrong public node detected"
$
(
_node_id
rootPublicFolder
)
/=
publicFolder2
testIsReadOnlyWorks
::
TestEnv
->
Assertion
testIsReadOnlyWorks
testEnv
=
do
...
...
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