From d9b8425b0f152898c305e2f98c3ff6df84bf7007 Mon Sep 17 00:00:00 2001 From: Stefan Matting Date: Thu, 24 Nov 2022 18:57:19 +0100 Subject: [PATCH] Factor check for MLS metadata into removeUser --- services/galley/src/Galley/API/Action.hs | 4 +--- services/galley/src/Galley/API/Federation.hs | 4 +--- services/galley/src/Galley/API/Internal.hs | 14 ++++++-------- services/galley/src/Galley/API/MLS/Removal.hs | 9 ++++----- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/services/galley/src/Galley/API/Action.hs b/services/galley/src/Galley/API/Action.hs index 5945098bf1d..2acdd7858c6 100644 --- a/services/galley/src/Galley/API/Action.hs +++ b/services/galley/src/Galley/API/Action.hs @@ -57,7 +57,6 @@ import Galley.API.Util import Galley.App import Galley.Data.Conversation import qualified Galley.Data.Conversation as Data -import qualified Galley.Data.Conversation.Types as Data import Galley.Data.Services import Galley.Data.Types import Galley.Effects @@ -326,8 +325,7 @@ performAction tag origUser lconv action = do } ) origUser - for_ (Data.mlsMetadata (tUnqualified lconv')) $ \meta -> - traverse_ (removeUser lconv' (cnvmlsGroupId meta)) victims + traverse_ (removeUser lconv') victims pure (mempty, action) SConversationRemoveMembersTag -> do let presentVictims = filter (isConvMemberL lconv) (toList action) diff --git a/services/galley/src/Galley/API/Federation.hs b/services/galley/src/Galley/API/Federation.hs index 47df2f89986..1ce9c5f3378 100644 --- a/services/galley/src/Galley/API/Federation.hs +++ b/services/galley/src/Galley/API/Federation.hs @@ -49,7 +49,6 @@ import Galley.API.Push import Galley.API.Util import Galley.App import qualified Galley.Data.Conversation as Data -import qualified Galley.Data.Conversation.Types as Data import Galley.Effects import qualified Galley.Effects.BrigAccess as E import Galley.Effects.ConversationStore (getConversation) @@ -500,8 +499,7 @@ onUserDeleted origDomain udcn = do Public.GlobalTeamConv -> pure () Public.RegularConv -> do let botsAndMembers = convBotsAndMembers conv - for_ (Data.mlsMetadata conv) $ \mlsMeta -> - removeUser (qualifyAs lc conv) (cnvmlsGroupId mlsMeta) (qUntagged deletedUser) + removeUser (qualifyAs lc conv) (qUntagged deletedUser) void $ notifyConversationAction (sing @'ConversationLeaveTag) diff --git a/services/galley/src/Galley/API/Internal.hs b/services/galley/src/Galley/API/Internal.hs index a9e832cba1f..b3ddbdd8a5e 100644 --- a/services/galley/src/Galley/API/Internal.hs +++ b/services/galley/src/Galley/API/Internal.hs @@ -708,10 +708,9 @@ rmUser lusr conn = do now <- input let deleteIfNeeded c = do when (tUnqualified lusr `isMember` Data.convLocalMembers c) $ do - for_ (Data.mlsMetadata c) $ \mlsMeta -> - runError (removeUser (qualifyAs lusr c) (cnvmlsGroupId mlsMeta) (qUntagged lusr)) >>= \case - Left e -> P.err $ Log.msg ("failed to send remove proposal: " <> internalErrorDescription e) - Right _ -> pure () + runError (removeUser (qualifyAs lusr c) (qUntagged lusr)) >>= \case + Left e -> P.err $ Log.msg ("failed to send remove proposal: " <> internalErrorDescription e) + Right _ -> pure () deleteMembers (Data.convId c) (UserList [tUnqualified lusr] []) for_ (bucketRemote (fmap rmId (Data.convRemoteMembers c))) $ notifyRemoteMembers now qUser (Data.convId c) let e = @@ -726,10 +725,9 @@ rmUser lusr conn = do . set Intra.pushRoute Intra.RouteDirect deleteClientsFromGlobal c = do - for_ (Data.mlsMetadata c) $ \mlsMeta -> - runError (removeUser (qualifyAs lusr c) (cnvmlsGroupId mlsMeta) (qUntagged lusr)) >>= \case - Left e -> P.err $ Log.msg ("failed to send remove proposal: " <> internalErrorDescription e) - Right _ -> pure () + runError (removeUser (qualifyAs lusr c) (qUntagged lusr)) >>= \case + Left e -> P.err $ Log.msg ("failed to send remove proposal: " <> internalErrorDescription e) + Right _ -> pure () deleteMembers (Data.convId c) (UserList [tUnqualified lusr] []) for_ (bucketRemote (fmap rmId (Data.convRemoteMembers c))) $ notifyRemoteMembers now qUser (Data.convId c) pure Nothing diff --git a/services/galley/src/Galley/API/MLS/Removal.hs b/services/galley/src/Galley/API/MLS/Removal.hs index b928988ac3b..f16edf2bd26 100644 --- a/services/galley/src/Galley/API/MLS/Removal.hs +++ b/services/galley/src/Galley/API/MLS/Removal.hs @@ -44,7 +44,6 @@ import Polysemy.Input import Polysemy.TinyLog import qualified System.Logger as Log import Wire.API.Conversation.Protocol -import Wire.API.MLS.Group import Wire.API.MLS.KeyPackage import Wire.API.MLS.Message import Wire.API.MLS.Proposal @@ -154,9 +153,9 @@ removeUser :: r ) => Local Data.Conversation -> - GroupId -> Qualified UserId -> Sem r () -removeUser lc groupId qusr = do - cm <- lookupMLSClients groupId - removeUserWithClientMap lc cm qusr +removeUser lc qusr = do + for_ (Data.mlsMetadata (tUnqualified lc)) $ \meta -> do + cm <- lookupMLSClients (cnvmlsGroupId meta) + removeUserWithClientMap lc cm qusr