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 deleteNode :: HasNodeError err
36 deleteNode u nodeId = do
37 node' <- N.getNode nodeId
38 if hasNodeType node' NodeUser
39 then panic "Not allowed to delete NodeUser (yet)"
40 else if hasNodeType node' NodeTeam
43 if _node_userId node' == uId
44 then N.deleteNode nodeId
45 else delFolderTeam u nodeId
46 else N.deleteNode nodeId