2 Module : Gargantext.Database.Action.Delete
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
10 TODO: right managements of nodes children of node Team
11 -- TODO add proper Right Management Type
17 module Gargantext.Database.Action.Delete
20 import Gargantext.Core.Types.Individu (User(..))
21 import Gargantext.Database.Action.Flow.Utils (getUserId)
22 import Gargantext.Database.Admin.Config (hasNodeType)
23 import Gargantext.Database.Admin.Types.Node (NodeId)
24 import Gargantext.Database.Admin.Types.Node -- (NodeType(..))
25 import Gargantext.Database.Prelude (Cmd)
26 import Gargantext.Database.Query.Table.Node.Error (HasNodeError)
27 import Gargantext.Database.Schema.Node
28 import Gargantext.Prelude
29 import qualified Gargantext.Database.Query.Table.Node as N (getNode, deleteNode)
30 import Gargantext.Database.Action.Share (delFolderTeam)
32 ------------------------------------------------------------------------
33 deleteNode :: HasNodeError err
37 deleteNode u nodeId = do
38 node' <- N.getNode nodeId
39 if hasNodeType node' NodeUser
40 then panic "Not allowed to delete NodeUser (yet)"
41 else if hasNodeType node' NodeTeam
44 if _node_userId node' == uId
45 then N.deleteNode nodeId
46 else delFolderTeam u nodeId
47 else N.deleteNode nodeId