-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FS-507] Support for Remote Welcome Messages (#2368)
* Use a new internal endpoint to insert a key package ref for a remote client Co-authored-by: Stefan Matting <[email protected]>
- Loading branch information
1 parent
7dd25b7
commit 4a3bea4
Showing
9 changed files
with
259 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Support remote welcome messages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,3 @@ | ||
-- This file is part of the Wire Server implementation. | ||
-- | ||
-- Copyright (C) 2020 Wire Swiss GmbH <[email protected]> | ||
-- | ||
-- This program is free software: you can redistribute it and/or modify it under | ||
-- the terms of the GNU Affero General Public License as published by the Free | ||
-- Software Foundation, either version 3 of the License, or (at your option) any | ||
-- later version. | ||
-- | ||
-- This program is distributed in the hope that it will be useful, but WITHOUT | ||
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
-- details. | ||
-- | ||
-- You should have received a copy of the GNU Affero General Public License along | ||
-- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} | ||
|
||
-- This file is part of the Wire Server implementation. | ||
-- | ||
-- Copyright (C) 2022 Wire Swiss GmbH <[email protected]> | ||
|
@@ -32,9 +14,12 @@ | |
-- | ||
-- You should have received a copy of the GNU Affero General Public License along | ||
-- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
{-# LANGUAGE RecordWildCards #-} | ||
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} | ||
|
||
module API.Federation where | ||
|
||
import API.MLS.Util | ||
import API.Util | ||
import Bilge | ||
import Bilge.Assert | ||
|
@@ -43,10 +28,11 @@ import Control.Lens hiding ((#)) | |
import Data.Aeson (ToJSON (..)) | ||
import qualified Data.Aeson as A | ||
import Data.ByteString.Conversion (toByteString') | ||
import Data.Default | ||
import Data.Domain | ||
import Data.Id (ConvId, Id (..), UserId, newClientId, randomId) | ||
import Data.Json.Util (Base64ByteString (..), toBase64Text) | ||
import Data.List.NonEmpty (NonEmpty (..)) | ||
import Data.Json.Util hiding ((#)) | ||
import Data.List.NonEmpty (NonEmpty (..), head) | ||
import Data.List1 | ||
import qualified Data.List1 as List1 | ||
import qualified Data.Map as Map | ||
|
@@ -106,7 +92,8 @@ tests s = | |
test s "POST /federation/on-message-sent : Receive a message from another backend" onMessageSent, | ||
test s "POST /federation/send-message : Post a message sent from another backend" sendMessage, | ||
test s "POST /federation/on-user-deleted-conversations : Remove deleted remote user from local conversations" onUserDeleted, | ||
test s "POST /federation/update-conversation : Update local conversation by a remote admin " updateConversationByRemoteAdmin | ||
test s "POST /federation/update-conversation : Update local conversation by a remote admin " updateConversationByRemoteAdmin, | ||
test s "POST /federation/mls-welcome : Post an MLS welcome message received from another backend" sendMLSWelcome | ||
] | ||
|
||
getConversationsAllFound :: TestM () | ||
|
@@ -1158,6 +1145,29 @@ updateConversationByRemoteAdmin = do | |
let convUpdate :: ConversationUpdate = fromRight (error $ "Could not parse ConversationUpdate from " <> show (frBody rpc)) $ A.eitherDecode (frBody rpc) | ||
pure (rpc, convUpdate) | ||
|
||
sendMLSWelcome :: TestM () | ||
sendMLSWelcome = do | ||
let aliceDomain = Domain "a.far-away.example.com" | ||
-- Alice is from the originating domain and Bob is local, i.e., on the receiving domain | ||
MessagingSetup {..} <- aliceInvitesBob (1, LocalUser) def {creatorOrigin = RemoteUser aliceDomain} | ||
let bob = users !! 0 | ||
bobClient = snd . Data.List.NonEmpty.head . pClients $ bob | ||
|
||
fedGalleyClient <- view tsFedGalleyClient | ||
cannon <- view tsCannon | ||
|
||
WS.bracketR cannon (qUnqualified (pUserId bob)) $ \wsB -> do | ||
-- send welcome message | ||
runFedClient @"mls-welcome" fedGalleyClient aliceDomain $ | ||
MLSWelcomeRequest | ||
(Base64ByteString welcome) | ||
[MLSWelcomeRecipient (qUnqualified . pUserId $ bob, bobClient)] | ||
|
||
-- check that the corresponding event is received | ||
void . liftIO $ | ||
WS.assertMatch (5 # WS.Second) wsB $ | ||
wsAssertMLSWelcome (pUserId bob) welcome | ||
|
||
getConvAction :: Sing tag -> SomeConversationAction -> Maybe (ConversationAction tag) | ||
getConvAction tquery (SomeConversationAction tag action) = | ||
case (tag, tquery) of | ||
|
Oops, something went wrong.