From 4a0229034f80b1e149130e65af1cf4d60ab83e84 Mon Sep 17 00:00:00 2001 From: Stefan Berthold Date: Thu, 4 May 2023 13:23:46 +0000 Subject: [PATCH 1/4] Add subconversation ID to RemoteMLSMessage --- libs/wire-api-federation/src/Wire/API/Federation/API/Galley.hs | 1 + services/galley/src/Galley/API/Federation.hs | 2 +- services/galley/src/Galley/API/MLS/Propagate.hs | 1 + services/galley/test/integration/API/MLS.hs | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/wire-api-federation/src/Wire/API/Federation/API/Galley.hs b/libs/wire-api-federation/src/Wire/API/Federation/API/Galley.hs index 06d3217cbdc..c649449d5a5 100644 --- a/libs/wire-api-federation/src/Wire/API/Federation/API/Galley.hs +++ b/libs/wire-api-federation/src/Wire/API/Federation/API/Galley.hs @@ -353,6 +353,7 @@ data RemoteMLSMessage = RemoteMLSMessage rmmMetadata :: MessageMetadata, rmmSender :: Qualified UserId, rmmConversation :: ConvId, + rmmSubConversation :: Maybe SubConvId, rmmRecipients :: [(UserId, ClientId)], rmmMessage :: Base64ByteString } diff --git a/services/galley/src/Galley/API/Federation.hs b/services/galley/src/Galley/API/Federation.hs index 389b9a4c225..cdbcdd67d2b 100644 --- a/services/galley/src/Galley/API/Federation.hs +++ b/services/galley/src/Galley/API/Federation.hs @@ -783,7 +783,7 @@ onMLSMessageSent domain rmm = let recipients = filter (\(u, _) -> Set.member u members) (F.rmmRecipients rmm) -- FUTUREWORK: support local bots let e = - Event (tUntagged rcnv) Nothing (F.rmmSender rmm) (F.rmmTime rmm) $ + Event (tUntagged rcnv) (F.rmmSubConversation rmm) (F.rmmSender rmm) (F.rmmTime rmm) $ EdMLSMessage (fromBase64ByteString (F.rmmMessage rmm)) let mkPush :: (UserId, ClientId) -> MessagePush 'NormalMessage mkPush uc = newMessagePush loc mempty Nothing (F.rmmMetadata rmm) uc e diff --git a/services/galley/src/Galley/API/MLS/Propagate.hs b/services/galley/src/Galley/API/MLS/Propagate.hs index 10d0dcedebe..dc58e9b350c 100644 --- a/services/galley/src/Galley/API/MLS/Propagate.hs +++ b/services/galley/src/Galley/API/MLS/Propagate.hs @@ -95,6 +95,7 @@ propagateMessage qusr lConvOrSub con msg cm = do rmmSender = qusr, rmmMetadata = mm, rmmConversation = qUnqualified qcnv, + rmmSubConversation = sconv, rmmRecipients = rs >>= remoteMemberMLSClients, rmmMessage = Base64ByteString msg.raw } diff --git a/services/galley/test/integration/API/MLS.hs b/services/galley/test/integration/API/MLS.hs index d25796947d8..8212f92a06b 100644 --- a/services/galley/test/integration/API/MLS.hs +++ b/services/galley/test/integration/API/MLS.hs @@ -1206,6 +1206,7 @@ testRemoteToRemote = do rmmMetadata = defMessageMetadata, rmmSender = qbob, rmmConversation = conv, + rmmSubConversation = Nothing, rmmRecipients = rcpts, rmmMessage = Base64ByteString txt } From 078aa17a0201cde154b17101c401ccc84ac7a75a Mon Sep 17 00:00:00 2001 From: Stefan Berthold Date: Thu, 4 May 2023 13:30:50 +0000 Subject: [PATCH 2/4] Add changelog --- changelog.d/6-federation/FS-1868 | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6-federation/FS-1868 diff --git a/changelog.d/6-federation/FS-1868 b/changelog.d/6-federation/FS-1868 new file mode 100644 index 00000000000..208bebcf0c3 --- /dev/null +++ b/changelog.d/6-federation/FS-1868 @@ -0,0 +1 @@ +Add subconversation ID to onMLSMessageSent request payload. From 0606d183c79ef3d614018f4ff5107b48dbce4929 Mon Sep 17 00:00:00 2001 From: Stefan Berthold Date: Thu, 4 May 2023 14:35:07 +0000 Subject: [PATCH 3/4] Add integration test --- services/galley/test/integration/API/MLS.hs | 60 +++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/services/galley/test/integration/API/MLS.hs b/services/galley/test/integration/API/MLS.hs index 8212f92a06b..14d8722f333 100644 --- a/services/galley/test/integration/API/MLS.hs +++ b/services/galley/test/integration/API/MLS.hs @@ -253,6 +253,10 @@ tests s = test s "delete subconversation as a remote member" (testRemoteMemberDeleteSubConv True), test s "delete subconversation as a remote non-member" (testRemoteMemberDeleteSubConv False), test s "delete parent conversation of a remote subconversation" testDeleteRemoteParentOfSubConv + ], + testGroup + "Remote Sender/Remote SubConversation" + [ test s "on-mls-message-sent in subconversation" testRemoteToRemoteInSub ] ], testGroup @@ -1222,6 +1226,62 @@ testRemoteToRemote = do -- eve should not receive the message WS.assertNoEvent (1 # Second) [wsE] +testRemoteToRemoteInSub :: TestM () +testRemoteToRemoteInSub = do + localDomain <- viewFederationDomain + c <- view tsCannon + alice <- randomUser + eve <- randomUser + bob <- randomId + conv <- randomId + let subConvId = SubConvId "conference" + aliceC1 = newClientId 0 + aliceC2 = newClientId 1 + eveC = newClientId 0 + bdom = Domain "bob.example.com" + qconv = Qualified conv bdom + qbob = Qualified bob bdom + qalice = Qualified alice localDomain + now <- liftIO getCurrentTime + fedGalleyClient <- view tsFedGalleyClient + + -- only add alice to the remote conversation + connectWithRemoteUser alice qbob + let cu = + ConversationUpdate + { cuTime = now, + cuOrigUserId = qbob, + cuConvId = conv, + cuAlreadyPresentUsers = [], + cuAction = + SomeConversationAction (sing @'ConversationJoinTag) (ConversationJoin (pure qalice) roleNameWireMember) + } + runFedClient @"on-conversation-updated" fedGalleyClient bdom cu + + let txt = "Hello from another backend" + rcpts = [(alice, aliceC1), (alice, aliceC2), (eve, eveC)] + rm = + RemoteMLSMessage + { rmmTime = now, + rmmMetadata = defMessageMetadata, + rmmSender = qbob, + rmmConversation = conv, + rmmSubConversation = Just subConvId, + rmmRecipients = rcpts, + rmmMessage = Base64ByteString txt + } + + -- send message to alice and check reception + WS.bracketAsClientRN c [(alice, aliceC1), (alice, aliceC2), (eve, eveC)] $ \[wsA1, wsA2, wsE] -> do + void $ runFedClient @"on-mls-message-sent" fedGalleyClient bdom rm + liftIO $ do + -- alice should receive the message on her first client + WS.assertMatch_ (5 # Second) wsA1 $ \n -> wsAssertMLSMessage (fmap (flip SubConv subConvId) qconv) qbob txt n + WS.assertMatch_ (5 # Second) wsA2 $ \n -> wsAssertMLSMessage (fmap (flip SubConv subConvId) qconv) qbob txt n + + -- eve should not receive the message + WS.assertNoEvent (1 # Second) [wsE] + testRemoteToLocal :: TestM () testRemoteToLocal = do -- alice is local, bob is remote From 018bf3148e9cd88bf8d701353bb5c01b8924360e Mon Sep 17 00:00:00 2001 From: Stefan Berthold Date: Thu, 4 May 2023 15:08:22 +0000 Subject: [PATCH 4/4] hi ci