diff --git a/services/galley/src/Galley/Cassandra/Conversation.hs b/services/galley/src/Galley/Cassandra/Conversation.hs index de72cc1264f..6711a92c18f 100644 --- a/services/galley/src/Galley/Cassandra/Conversation.hs +++ b/services/galley/src/Galley/Cassandra/Conversation.hs @@ -268,7 +268,8 @@ getGlobalTeamConversationById lconv = do pure $ toGlobalConv mconv where toGlobalConv mconv = do - (muid, mname, mtid, mgid, mepoch, mcs) <- mconv + (muid, mname, mtid, mty, mgid, mepoch, mcs) <- mconv + guard (mty == Just GlobalTeamConv) tid <- mtid name <- mname mlsData <- ConversationMLSData <$> mgid <*> (mepoch <|> Just (Epoch 0)) <*> mcs diff --git a/services/galley/src/Galley/Cassandra/Queries.hs b/services/galley/src/Galley/Cassandra/Queries.hs index ce8ec549730..085f0366749 100644 --- a/services/galley/src/Galley/Cassandra/Queries.hs +++ b/services/galley/src/Galley/Cassandra/Queries.hs @@ -226,11 +226,12 @@ selectGlobalTeamConv :: ( Maybe UserId, Maybe Text, Maybe TeamId, + Maybe ConvType, Maybe GroupId, Maybe Epoch, Maybe CipherSuiteTag ) -selectGlobalTeamConv = "select creator, name, team, group_id, epoch, cipher_suite from conversation where conv = ?" +selectGlobalTeamConv = "select creator, name, team, type, group_id, epoch, cipher_suite from conversation where conv = ?" selectReceiptMode :: PrepQuery R (Identity ConvId) (Identity (Maybe ReceiptMode)) selectReceiptMode = "select receipt_mode from conversation where conv = ?" diff --git a/services/galley/test/integration/API/MLS.hs b/services/galley/test/integration/API/MLS.hs index 0de8fba4816..61e28abb3c4 100644 --- a/services/galley/test/integration/API/MLS.hs +++ b/services/galley/test/integration/API/MLS.hs @@ -20,13 +20,14 @@ module API.MLS (tests) where import API.MLS.Util --- import API.SQS +import API.SQS import API.Util as Util import Bilge hiding (head) import Bilge.Assert import Cassandra -- import Control.Error.Util (hush) -import Control.Lens (view) -- , (^.)) +-- import Control.Lens (view, (^.)) +import Control.Lens (view) import qualified Control.Monad.State as State import Crypto.Error import qualified Crypto.PubKey.Ed25519 as Ed25519 @@ -193,7 +194,8 @@ tests s = "CommitBundle" [ test s "add user with a commit bundle" testAddUserWithBundle, test s "add user with a commit bundle to a remote conversation" testAddUserToRemoteConvWithBundle, - test s "remote user posts commit bundle" testRemoteUserPostsCommitBundle + test s "remote user posts commit bundle" testRemoteUserPostsCommitBundle, + test s "add user with a commit bundle and a team conv" testAddTeamUserWithBundle ], -- testGroup -- "GlobalTeamConv" @@ -2444,3 +2446,45 @@ testSelfConversationLeave = do const 403 === statusCode const (Just "invalid-op") === fmap Wai.label . responseJsonError WS.assertNoEvent (1 # WS.Second) wss + +testAddTeamUserWithBundle :: TestM () +testAddTeamUserWithBundle = do + [alice, bob] <- createAndConnectUsers [Nothing, Nothing] + tid <- createBindingTeamInternal "sample-team" (qUnqualified alice) + assertQueue "create team" tActivate + assertQueueEmpty + + (qcnv, commit) <- runMLSTest $ do + (alice1 : bobClients) <- traverse createMLSClient [alice, bob, bob] + traverse_ uploadNewKeyPackage bobClients + (_, qcnv) <- setupMLSGroupWithTeam tid alice1 + commit <- createAddCommit alice1 [bob] + welcome <- assertJust (mpWelcome commit) + + events <- mlsBracket bobClients $ \wss -> do + events <- sendAndConsumeCommitBundle commit + for_ (zip bobClients wss) $ \(c, ws) -> + WS.assertMatch (5 # Second) ws $ + wsAssertMLSWelcome (cidQualifiedUser c) welcome + pure events + + event <- assertOne events + liftIO $ assertJoinEvent qcnv alice [bob] roleNameWireMember event + pure (qcnv, commit) + + -- check that bob can now see the conversation + convs <- + responseJsonError + =<< getConvs (qUnqualified bob) Nothing Nothing + returnedGS diff --git a/services/galley/test/integration/API/MLS/Util.hs b/services/galley/test/integration/API/MLS/Util.hs index 59d9e89be1c..275fc401f37 100644 --- a/services/galley/test/integration/API/MLS/Util.hs +++ b/services/galley/test/integration/API/MLS/Util.hs @@ -425,6 +425,19 @@ setupMLSGroup creator = setupMLSGroupWithConv action creator ) TeamId -> ClientIdentity -> MLSTest (GroupId, Qualified ConvId) +setupMLSGroupWithTeam tid creator = setupMLSGroupWithConv action creator + where + action = + responseJsonError + =<< liftTest + ( postConvQualified + (ciUser creator) + (defNewMLSConv (ciClient creator)) {newConvTeam = Just $ ConvTeamInfo tid} + ) + ClientIdentity -> MLSTest (GroupId, Qualified ConvId) setupMLSSelfGroup creator = setupMLSGroupWithConv action creator diff --git a/services/galley/test/integration/API/Util.hs b/services/galley/test/integration/API/Util.hs index 577e7bab3bd..a8d75b9c175 100644 --- a/services/galley/test/integration/API/Util.hs +++ b/services/galley/test/integration/API/Util.hs @@ -727,7 +727,8 @@ defNewMLSConv :: ClientId -> NewConv defNewMLSConv c = defNewProteusConv { newConvProtocol = ProtocolMLSTag, - newConvCreatorClient = Just c + newConvCreatorClient = Just c, + newConvName = Just (unsafeRange "Test conv") } postConvQualified ::