@@ -37,6 +37,7 @@ module Galley.API.Query
37
37
getConversationGuestLinksStatus ,
38
38
ensureConvAdmin ,
39
39
getMLSSelfConversation ,
40
+ getMLSSelfConversationWithError ,
40
41
)
41
42
where
42
43
@@ -450,7 +451,14 @@ conversationIdsPageFrom lusr state = do
450
451
-- NOTE: Getting the MLS self-conversation creates it in case it does not
451
452
-- exist yet. This is to ensure it is automatically listed without needing to
452
453
-- 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
454
462
conversationIdsPageFromV2 ListGlobalSelf lusr state
455
463
456
464
getConversations ::
@@ -699,6 +707,29 @@ getConversationGuestLinksFeatureStatus mbTid = do
699
707
mbLockStatus <- TeamFeatures. getFeatureLockStatus @ db (Proxy @ GuestLinksConfig ) tid
700
708
pure $ computeFeatureConfigForTeamUser mbConfigNoLock mbLockStatus defaultStatus
701
709
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
+
702
733
-- | Get an MLS self conversation. In case it does not exist, it is partially
703
734
-- created in the database. The part that is not written is the epoch number;
704
735
-- the number is inserted only upon the first commit. With this we avoid race
@@ -717,20 +748,10 @@ getMLSSelfConversation ::
717
748
Local UserId ->
718
749
Sem r Conversation
719
750
getMLSSelfConversation lusr = do
720
- let selfConvId = mlsSelfConvId usr
751
+ let selfConvId = mlsSelfConvId . tUnqualified $ lusr
721
752
mconv <- E. getConversation selfConvId
722
- cnv <- maybe create pure mconv
753
+ cnv <- maybe ( E. createMLSSelfConversation lusr) pure mconv
723
754
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."
734
755
735
756
-------------------------------------------------------------------------------
736
757
-- Helpers
0 commit comments