Commit 62d9bdc6 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] Tree root design fun.

parent 76268fc5
......@@ -367,14 +367,14 @@ serverPrivateGargAPI _ = throwAll' (_ServerError # err401)
-- TODO-SECURITY admin only: withAdmin
-- Question: How do we mark admins?
serverGargAdminAPI :: NodeId -> GargServer GargAdminAPI
serverGargAdminAPI n = roots n
:<|> nodesAPI
serverGargAdminAPI :: GargServer GargAdminAPI
serverGargAdminAPI = roots
:<|> nodesAPI
serverPrivateGargAPI' :: AuthenticatedUser -> GargServer GargPrivateAPI'
serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
= serverGargAdminAPI (NodeId 0)
= serverGargAdminAPI
:<|> nodeAPI (Proxy :: Proxy HyperdataAny) uid
:<|> nodeAPI (Proxy :: Proxy HyperdataCorpus) uid
:<|> nodeNodeAPI (Proxy :: Proxy HyperdataAny) uid
......
......@@ -97,8 +97,8 @@ type Roots = Get '[JSON] [NodeUser]
:<|> Put '[JSON] Int -- TODO
-- | TODO: access by admin only
roots :: NodeId -> GargServer Roots
roots n = getNodesWithParentId n
roots :: GargServer Roots
roots = getNodesWithParentId Nothing
:<|> pure (panic "not implemented yet") -- TODO use patch map to update what we need
-------------------------------------------------------------------
......
......@@ -334,9 +334,13 @@ getNodesWith parentId _ nodeType maybeOffset maybeLimit =
-- TODO: Why is the second parameter ignored?
-- TODO: Why not use getNodesWith?
getNodesWithParentId :: (Hyperdata a, QueryRunnerColumnDefault PGJsonb a)
=> NodeId
=> Maybe NodeId
-> Cmd err [Node a]
getNodesWithParentId n = runOpaQuery $ selectNodesWithParentID n
getNodesWithParentId n = runOpaQuery $ selectNodesWithParentID n'
where
n' = case n of
Just n'' -> n''
Nothing -> 0
------------------------------------------------------------------------
getDocumentsV3WithParentId :: NodeId -> Cmd err [Node HyperdataDocumentV3]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment