Commit da90f04c authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FEAT PUBLIC] fix API

parent f58dad0d
......@@ -46,6 +46,7 @@ import Gargantext.Core.Types (NodeTableResult)
import Gargantext.Core.Types.Individu (User(..))
import Gargantext.Core.Types.Main (Tree, NodeTree)
import Gargantext.Database.Action.Flow.Pairing (pairing)
import Gargantext.Database.Action.Share (unPublish)
import Gargantext.Database.Admin.Types.Node
import Gargantext.Database.Prelude -- (Cmd, CmdM)
import Gargantext.Database.Query.Facet (FacetDoc, OrderBy(..))
......@@ -144,6 +145,7 @@ type NodeAPI a = Get '[JSON] (Node a)
:<|> "phylo" :> PhyloAPI
-- :<|> "add" :> NodeAddAPI
:<|> "move" :> MoveAPI
:<|> "unpublish" :> Post '[JSON] Int
-- TODO-ACCESS: check userId CanRenameNode nodeId
-- TODO-EVENTS: NodeRenamed RenameNode or re-use some more general NodeEdited...
......@@ -219,6 +221,8 @@ nodeAPI p uId id' = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode
:<|> moveNode (RootId $ NodeId uId) id'
-- :<|> nodeAddAPI id'
-- :<|> postUpload id'
:<|> unPublish (RootId $ NodeId uId) id'
------------------------------------------------------------------------
data RenameNode = RenameNode { r_name :: Text }
......
......@@ -36,8 +36,10 @@ data ShareNode = ShareTeam { username :: Text }
deriving (Generic)
------------------------------------------------------------------------
-- TODO unPrefix "pn_" FromJSON, ToJSON, ToSchema, adapt frontend.
instance FromJSON ShareNode
instance ToJSON ShareNode
instance FromJSON ShareNode where
parseJSON = genericParseJSON (defaultOptions { sumEncoding = ObjectWithSingleField })
instance ToJSON ShareNode where
toJSON = genericToJSON (defaultOptions { sumEncoding = ObjectWithSingleField })
instance ToSchema ShareNode
instance Arbitrary ShareNode where
arbitrary = elements [ ShareTeam "user1"
......@@ -59,3 +61,7 @@ type API = Summary " Share Node with username"
:> ReqBody '[JSON] ShareNode
:> Post '[JSON] Int
......@@ -65,6 +65,7 @@ getFolderId u nt = do
Nothing -> panic "No folder shared found"
Just f -> pure (_node_id f)
------------------------------------------------------------------------
type TeamId = NodeId
delFolderTeam :: User -> TeamId -> Cmd err Int
......@@ -77,4 +78,3 @@ unPublish u nId = do
folderId <- getFolderId u NodeFolderPublic
deleteNodeNode folderId nId
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