Skip to content

Commit

Permalink
Make internal endpoint internal
Browse files Browse the repository at this point in the history
  • Loading branch information
elland committed Feb 8, 2023
1 parent d739343 commit 90b95a0
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 43 deletions.
12 changes: 0 additions & 12 deletions libs/wire-api/src/Wire/API/Routes/Public/Galley/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -398,18 +398,6 @@ type ConversationAPI =
Conversation
)
)
:<|> Named
"get-conversation-clients"
( Summary "Get mls conversation client list"
:> ZLocalUser
:> CanThrow 'ConvNotFound
:> "conversation"
:> Capture "cnv" ConvId
:> MultiVerb1
'GET
'[JSON]
(Respond 200 "Clients" ClientList)
)
:<|> Named
"get-subconversation"
( Summary "Get information about an MLS subconversation"
Expand Down
34 changes: 33 additions & 1 deletion services/galley/src/Galley/API/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ import qualified Servant hiding (WithStatus)
import System.Logger.Class hiding (Path, name)
import qualified System.Logger.Class as Log
import Wire.API.ApplyMods
import Wire.API.Conversation hiding (Member)
import Wire.API.Conversation
import Wire.API.Conversation.Action
import Wire.API.Conversation.Role
import Wire.API.CustomBackend
Expand All @@ -111,6 +111,9 @@ import Wire.API.Team.Member
import Wire.API.Team.SearchVisibility
import Wire.Sem.Paging
import Wire.Sem.Paging.Cassandra
import qualified Galley.Effects.MemberStore as E
import qualified Data.Map as Map
import Wire.API.MLS.Group

type LegalHoldFeatureStatusChangeErrors =
'( 'ActionDenied 'RemoveConversationMember,
Expand Down Expand Up @@ -271,6 +274,19 @@ type InternalAPIBase =
:> ReqBody '[Servant.JSON] Connect
:> ConversationVerb
)
-- This endpoint is meant for testing membership of a conversation
:<|> Named
"get-conversation-clients"
( Summary "Get mls conversation client list"
:> ZLocalUser
:> CanThrow 'ConvNotFound
:> "conversation"
:> Capture "cnv" ConvId
:> MultiVerb1
'GET
'[Servant.JSON]
(Respond 200 "Clients" ClientList)
)
:<|> Named
"guard-legalhold-policy-conflicts"
( "guard-legalhold-policy-conflicts"
Expand Down Expand Up @@ -479,6 +495,7 @@ internalAPI =
mkNamedAPI @"status" (pure ())
<@> mkNamedAPI @"delete-user" (callsFed rmUser)
<@> mkNamedAPI @"connect" (callsFed Create.createConnectConversation)
<@> mkNamedAPI @"get-conversation-clients" iGetMLSClientListForConv
<@> mkNamedAPI @"guard-legalhold-policy-conflicts" guardLegalholdPolicyConflictsH
<@> legalholdWhitelistedTeamsAPI
<@> iTeamsAPI
Expand Down Expand Up @@ -843,3 +860,18 @@ guardLegalholdPolicyConflictsH ::
guardLegalholdPolicyConflictsH glh = do
mapError @LegalholdConflicts (const $ Tagged @'MissingLegalholdConsent ()) $
guardLegalholdPolicyConflicts (glhProtectee glh) (glhUserClients glh)

-- | Get an MLS conversation client list
iGetMLSClientListForConv ::
forall r.
Members
'[ MemberStore,
ErrorS 'ConvNotFound
]
r =>
Local UserId ->
ConvId ->
Sem r ClientList
iGetMLSClientListForConv lusr cnv = do
cm <- E.lookupMLSClients (convToGroupId (qualifyAs lusr cnv))
pure $ ClientList (concatMap (Map.keys . snd) (Map.assocs cm))
1 change: 0 additions & 1 deletion services/galley/src/Galley/API/Public/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ conversationAPI =
<@> mkNamedAPI @"create-self-conversation@v2" createProteusSelfConversation
<@> mkNamedAPI @"create-self-conversation" createProteusSelfConversation
<@> mkNamedAPI @"get-mls-self-conversation" getMLSSelfConversationWithError
<@> mkNamedAPI @"get-conversation-clients" getMLSClientListForConv
<@> mkNamedAPI @"get-subconversation" (callsFed getSubConversation)
<@> mkNamedAPI @"leave-subconversation" (callsFed leaveSubConversation)
<@> mkNamedAPI @"delete-subconversation" (callsFed deleteSubConversation)
Expand Down
17 changes: 0 additions & 17 deletions services/galley/src/Galley/API/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ module Galley.API.Query
ensureConvAdmin,
getMLSSelfConversation,
getMLSSelfConversationWithError,
getMLSClientListForConv,
)
where

Expand Down Expand Up @@ -93,7 +92,6 @@ import Wire.API.Error.Galley
import Wire.API.Federation.API
import Wire.API.Federation.API.Galley
import Wire.API.Federation.Error
import Wire.API.MLS.Group
import qualified Wire.API.Provider.Bot as Public
import qualified Wire.API.Routes.MultiTablePaging as Public
import Wire.API.Team.Feature as Public hiding (setStatus)
Expand Down Expand Up @@ -719,21 +717,6 @@ getMLSSelfConversation lusr = do
cnv <- maybe (E.createMLSSelfConversation lusr) pure mconv
conversationView lusr cnv

-- | Get an MLS conversation client list
getMLSClientListForConv ::
forall r.
Members
'[ MemberStore,
ErrorS 'ConvNotFound
]
r =>
Local UserId ->
ConvId ->
Sem r ClientList
getMLSClientListForConv lusr cnv = do
cm <- E.lookupMLSClients (convToGroupId (qualifyAs lusr cnv))
pure $ ClientList (concat $ Map.keys . snd <$> Map.assocs cm)

-------------------------------------------------------------------------------
-- Helpers

Expand Down
11 changes: 0 additions & 11 deletions services/galley/test/integration/API/MLS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3145,17 +3145,6 @@ testCreatorRemovesUserFromParent = do
getSubConv (qUnqualified bob) qcnv (SubConvId "conference")
!!! const 403 === statusCode

clients <- getConvClients (qUnqualified alice) (qUnqualified qcnv)
convs <- getAllConvs (qUnqualified bob)
liftIO $ do
assertEqual
"Parent conversation client list mismatch"
(sort $ clClients clients)
(sort $ ciClient <$> [alice1, charlie1, charlie2])
assertBool
"bob is not longer part of conversation after the commit"
(qcnv `notElem` map cnvQualifiedId convs)

-- charlie sees updated memberlist
sub1 :: PublicSubConversation <-
responseJsonError
Expand Down
2 changes: 1 addition & 1 deletion services/galley/test/integration/API/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ getConvClients usr cnv = do
responseJsonError
=<< get
( g
. paths ["conversation", toByteString' cnv]
. paths ["i", "conversation", toByteString' cnv]
. zUser usr
. zConn "conn"
)
Expand Down

0 comments on commit 90b95a0

Please sign in to comment.