From acf5d67bb0fc9e61753e927bb8f7751377a33c26 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 | 3 +-- services/galley/src/Galley/API/Federation.hs | 3 +-- services/galley/src/Galley/API/Internal.hs | 14 ++++++-------- services/galley/src/Galley/API/MLS/Removal.hs | 9 ++++----- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/services/galley/src/Galley/API/Action.hs b/services/galley/src/Galley/API/Action.hs index 5945098bf1d..2985f407dc4 100644 --- a/services/galley/src/Galley/API/Action.hs +++ b/services/galley/src/Galley/API/Action.hs @@ -326,8 +326,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..de3f215ae36 100644 --- a/services/galley/src/Galley/API/Federation.hs +++ b/services/galley/src/Galley/API/Federation.hs @@ -500,8 +500,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