]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/API/Members.hs
Merge remote-tracking branch 'origin/dev-phylo' into dev
[gargantext.git] / src / Gargantext / API / Members.hs
1 module Gargantext.API.Members where
2
3 import Gargantext.Prelude
4 import Gargantext.API.Prelude
5 import Servant
6 import Data.Text (Text)
7 import Gargantext.API.Admin.EnvTypes (Env)
8 import Gargantext.Core.Types (UserId)
9 import Gargantext.Database.Admin.Types.Node (NodeType(NodeTeam))
10 import Gargantext.Database.Query.Table.Node (getNodesIdWithType)
11 import Gargantext.Database.Action.Share (membersOf)
12 import Gargantext.Database.Prelude (CmdCommon)
13 import Control.Monad.Extra (concatMapM)
14
15 type MembersAPI = Get '[JSON] [Text]
16
17 members :: UserId -> ServerT MembersAPI (GargM Env GargError)
18 members _ = do
19 getMembers
20
21 getMembers :: (CmdCommon env) =>
22 GargM env GargError [Text]
23 getMembers = do
24 teamNodeIds <- getNodesIdWithType NodeTeam
25 m <- concatMapM membersOf teamNodeIds
26 pure $ map fst m