Skip to content

Commit a4db91d

Browse files
authored
Merge pull request #2894 from wireapp/release_2022-12-01_16_05
Release 2022-12-01 - (expected chart version 4.28.0)
2 parents 9a58ed3 + ab877c6 commit a4db91d

File tree

4 files changed

+51
-16
lines changed

4 files changed

+51
-16
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [2022-12-01] (Chart Release 4.27.0)
1+
# [2022-12-01] (Chart Release 4.28.0)
22

33
## Release notes
44

@@ -27,6 +27,8 @@
2727

2828
* Avoid client deletion edge case condition which can lead to inconsistent data between brig and galley's clients tables. (#2830)
2929

30+
* Do not throw 500 when listing conversations and MLS is not configured (#2893)
31+
3032
* Do not list MLS self-conversation in client API v1 and v2 if it exists (#2872)
3133

3234
* Prevention of storing unnecessary data in the database if adding a bot to a conversation fails. (#2870)

services/galley/src/Galley/API/Public/Conversation.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ conversationAPI =
4444
<@> mkNamedAPI @"get-conversation-by-reusable-code" (getConversationByReusableCode @Cassandra)
4545
<@> mkNamedAPI @"create-group-conversation" createGroupConversation
4646
<@> mkNamedAPI @"create-self-conversation" createProteusSelfConversation
47-
<@> mkNamedAPI @"get-mls-self-conversation" getMLSSelfConversation
47+
<@> mkNamedAPI @"get-mls-self-conversation" getMLSSelfConversationWithError
4848
<@> mkNamedAPI @"create-one-to-one-conversation" createOne2OneConversation
4949
<@> mkNamedAPI @"add-members-to-conversation-unqualified" addMembersUnqualified
5050
<@> mkNamedAPI @"add-members-to-conversation-unqualified2" addMembersUnqualifiedV2

services/galley/src/Galley/API/Query.hs

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module Galley.API.Query
3737
getConversationGuestLinksStatus,
3838
ensureConvAdmin,
3939
getMLSSelfConversation,
40+
getMLSSelfConversationWithError,
4041
)
4142
where
4243

@@ -450,7 +451,14 @@ conversationIdsPageFrom lusr state = do
450451
-- NOTE: Getting the MLS self-conversation creates it in case it does not
451452
-- exist yet. This is to ensure it is automatically listed without needing to
452453
-- create it separately.
453-
void $ getMLSSelfConversation lusr
454+
--
455+
-- Make sure that in case MLS is not configured (the non-existance of the
456+
-- backend removal key is a proxy for it) the self-conversation is not
457+
-- returned or attempted to be created; in that case we skip anything related
458+
-- to it.
459+
whenM (isJust <$> getMLSRemovalKey)
460+
. void
461+
$ getMLSSelfConversation lusr
454462
conversationIdsPageFromV2 ListGlobalSelf lusr state
455463

456464
getConversations ::
@@ -699,6 +707,29 @@ getConversationGuestLinksFeatureStatus mbTid = do
699707
mbLockStatus <- TeamFeatures.getFeatureLockStatus @db (Proxy @GuestLinksConfig) tid
700708
pure $ computeFeatureConfigForTeamUser mbConfigNoLock mbLockStatus defaultStatus
701709

710+
-- | The same as 'getMLSSelfConversation', but it throws an error in case the
711+
-- backend is not configured for MLS (the proxy for it being the existance of
712+
-- the backend removal key).
713+
getMLSSelfConversationWithError ::
714+
forall r.
715+
Members
716+
'[ ConversationStore,
717+
Error InternalError,
718+
Input Env,
719+
P.TinyLog
720+
]
721+
r =>
722+
Local UserId ->
723+
Sem r Conversation
724+
getMLSSelfConversationWithError lusr = do
725+
unlessM (isJust <$> getMLSRemovalKey) $
726+
throw (InternalErrorWithDescription noKeyMsg)
727+
getMLSSelfConversation lusr
728+
where
729+
noKeyMsg =
730+
"No backend removal key is configured (See 'mlsPrivateKeyPaths'"
731+
<> "in galley's config). Refusing to create MLS conversation."
732+
702733
-- | Get an MLS self conversation. In case it does not exist, it is partially
703734
-- created in the database. The part that is not written is the epoch number;
704735
-- the number is inserted only upon the first commit. With this we avoid race
@@ -717,20 +748,10 @@ getMLSSelfConversation ::
717748
Local UserId ->
718749
Sem r Conversation
719750
getMLSSelfConversation lusr = do
720-
let selfConvId = mlsSelfConvId usr
751+
let selfConvId = mlsSelfConvId . tUnqualified $ lusr
721752
mconv <- E.getConversation selfConvId
722-
cnv <- maybe create pure mconv
753+
cnv <- maybe (E.createMLSSelfConversation lusr) pure mconv
723754
conversationView lusr cnv
724-
where
725-
usr = tUnqualified lusr
726-
create :: Sem r Data.Conversation
727-
create = do
728-
unlessM (isJust <$> getMLSRemovalKey) $
729-
throw (InternalErrorWithDescription noKeyMsg)
730-
E.createMLSSelfConversation lusr
731-
noKeyMsg =
732-
"No backend removal key is configured (See 'mlsPrivateKeyPaths'"
733-
<> "in galley's config). Refusing to create MLS conversation."
734755

735756
-------------------------------------------------------------------------------
736757
-- Helpers

services/galley/test/integration/API/MLS.hs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Bilge.Assert
2727
import Cassandra
2828
-- import Control.Error.Util (hush)
2929
-- import Control.Lens (view, (^.))
30-
import Control.Lens (view)
30+
import Control.Lens (view, (%~), (.~))
3131
import qualified Control.Monad.State as State
3232
import Crypto.Error
3333
import qualified Crypto.PubKey.Ed25519 as Ed25519
@@ -48,6 +48,7 @@ import Data.String.Conversions
4848
import qualified Data.Text as T
4949
import Data.Time
5050
import Federator.MockServer hiding (withTempMockFederator)
51+
import qualified Galley.Options as Opts
5152
-- import Galley.Data.Conversation
5253
-- import Galley.Options
5354
import Imports
@@ -213,6 +214,7 @@ tests s =
213214
[ test s "create a self conversation" testSelfConversation,
214215
test s "do not list a self conversation below v3" $ testSelfConversationList True,
215216
test s "list a self conversation automatically from v3" $ testSelfConversationList False,
217+
test s "listing conversations without MLS configured" testSelfConversationMLSNotConfigured,
216218
test s "attempt to add another user to a conversation fails" testSelfConversationOtherUser,
217219
test s "attempt to leave fails" testSelfConversationLeave
218220
]
@@ -2416,6 +2418,16 @@ testSelfConversationList isBelowV3 = do
24162418
<!! const 200 === statusCode
24172419
pure $ foldr (<|>) Nothing $ guard . isMLSSelf u <$> mtpResults convIds
24182420

2421+
testSelfConversationMLSNotConfigured :: TestM ()
2422+
testSelfConversationMLSNotConfigured = do
2423+
alice <- randomUser
2424+
let paginationOpts = GetPaginatedConversationIds Nothing (toRange (Proxy @100))
2425+
noMLS = Opts.optSettings %~ Opts.setMlsPrivateKeyPaths .~ Nothing
2426+
runMLSTest
2427+
. liftTest
2428+
. withSettingsOverrides noMLS
2429+
$ listConvIds alice paginationOpts !!! const 200 === statusCode
2430+
24192431
testSelfConversationOtherUser :: TestM ()
24202432
testSelfConversationOtherUser = do
24212433
users@[_alice, bob] <- createAndConnectUsers [Nothing, Nothing]

0 commit comments

Comments
 (0)