Commit 1ae1a49d authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] API to unpublish: ok

parent bdcd2dde
...@@ -46,7 +46,6 @@ import Gargantext.Core.Types (NodeTableResult) ...@@ -46,7 +46,6 @@ import Gargantext.Core.Types (NodeTableResult)
import Gargantext.Core.Types.Individu (User(..)) import Gargantext.Core.Types.Individu (User(..))
import Gargantext.Core.Types.Main (Tree, NodeTree) import Gargantext.Core.Types.Main (Tree, NodeTree)
import Gargantext.Database.Action.Flow.Pairing (pairing) import Gargantext.Database.Action.Flow.Pairing (pairing)
import Gargantext.Database.Action.Share (unPublish)
import Gargantext.Database.Admin.Types.Node import Gargantext.Database.Admin.Types.Node
import Gargantext.Database.Prelude -- (Cmd, CmdM) import Gargantext.Database.Prelude -- (Cmd, CmdM)
import Gargantext.Database.Query.Facet (FacetDoc, OrderBy(..)) import Gargantext.Database.Query.Facet (FacetDoc, OrderBy(..))
...@@ -145,7 +144,7 @@ type NodeAPI a = Get '[JSON] (Node a) ...@@ -145,7 +144,7 @@ type NodeAPI a = Get '[JSON] (Node a)
:<|> "phylo" :> PhyloAPI :<|> "phylo" :> PhyloAPI
-- :<|> "add" :> NodeAddAPI -- :<|> "add" :> NodeAddAPI
:<|> "move" :> MoveAPI :<|> "move" :> MoveAPI
:<|> "unpublish" :> Put '[JSON] Int :<|> "unpublish" :> Share.Unpublish
-- TODO-ACCESS: check userId CanRenameNode nodeId -- TODO-ACCESS: check userId CanRenameNode nodeId
-- TODO-EVENTS: NodeRenamed RenameNode or re-use some more general NodeEdited... -- TODO-EVENTS: NodeRenamed RenameNode or re-use some more general NodeEdited...
...@@ -221,7 +220,7 @@ nodeAPI p uId id' = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode ...@@ -221,7 +220,7 @@ nodeAPI p uId id' = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode
:<|> moveNode (RootId $ NodeId uId) id' :<|> moveNode (RootId $ NodeId uId) id'
-- :<|> nodeAddAPI id' -- :<|> nodeAddAPI id'
-- :<|> postUpload id' -- :<|> postUpload id'
:<|> unPublish (RootId $ NodeId uId) id' :<|> Share.unPublish id'
------------------------------------------------------------------------ ------------------------------------------------------------------------
......
...@@ -21,10 +21,12 @@ import Data.Swagger ...@@ -21,10 +21,12 @@ import Data.Swagger
import Data.Text (Text) import Data.Text (Text)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Gargantext.Core.Types.Individu (User(..)) import Gargantext.Core.Types.Individu (User(..))
import Gargantext.Database.Action.Share (shareNodeWith, ShareNodeWith(..)) import Gargantext.Database.Action.Share (ShareNodeWith(..))
import Gargantext.Database.Action.Share as DB (shareNodeWith, unPublish)
import Gargantext.Database.Admin.Types.Node import Gargantext.Database.Admin.Types.Node
import Gargantext.Database.Prelude import Gargantext.Database.Prelude
import Gargantext.Database.Query.Table.Node.Error (HasNodeError(..)) import Gargantext.Database.Query.Table.Node.Error (HasNodeError(..))
import Gargantext.API.Prelude
import Gargantext.Prelude import Gargantext.Prelude
import Servant import Servant
import Test.QuickCheck (elements) import Test.QuickCheck (elements)
...@@ -52,16 +54,19 @@ api :: HasNodeError err ...@@ -52,16 +54,19 @@ api :: HasNodeError err
-> ShareNodeParams -> ShareNodeParams
-> Cmd err Int -> Cmd err Int
api nId (ShareTeamParams user) = api nId (ShareTeamParams user) =
fromIntegral <$> shareNodeWith (ShareNodeWith_User NodeFolderShared (UserName user)) nId fromIntegral <$> DB.shareNodeWith (ShareNodeWith_User NodeFolderShared (UserName user)) nId
api nId2 (SharePublicParams nId1) = api nId2 (SharePublicParams nId1) =
fromIntegral <$> shareNodeWith (ShareNodeWith_Node NodeFolderPublic nId1) nId2 fromIntegral <$> DB.shareNodeWith (ShareNodeWith_Node NodeFolderPublic nId1) nId2
------------------------------------------------------------------------ ------------------------------------------------------------------------
type API = Summary " Share Node with username" type API = Summary " Share Node with username"
:> ReqBody '[JSON] ShareNodeParams :> ReqBody '[JSON] ShareNodeParams
:> Post '[JSON] Int :> Post '[JSON] Int
------------------------------------------------------------------------
type Unpublish = Summary " Unpublish Node"
:> Capture "node_id" NodeId
:> Put '[JSON] Int
unPublish :: NodeId -> GargServer Unpublish
unPublish n = DB.unPublish n
...@@ -87,8 +87,9 @@ delFolderTeam u nId = do ...@@ -87,8 +87,9 @@ delFolderTeam u nId = do
folderSharedId <- getFolderId u NodeFolderShared folderSharedId <- getFolderId u NodeFolderShared
deleteNodeNode folderSharedId nId deleteNodeNode folderSharedId nId
unPublish :: HasNodeError err => User -> NodeId -> Cmd err Int
unPublish u nId = do unPublish :: HasNodeError err
folderId <- getFolderId u NodeFolderPublic => ParentId -> NodeId
deleteNodeNode folderId nId -> Cmd err Int
unPublish p n = deleteNodeNode p n
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