Skip to content

Commit

Permalink
Factor check for MLS metadata into removeUser
Browse files Browse the repository at this point in the history
  • Loading branch information
smatting committed Nov 24, 2022
1 parent 8e92789 commit acf5d67
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
3 changes: 1 addition & 2 deletions services/galley/src/Galley/API/Action.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions services/galley/src/Galley/API/Federation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 6 additions & 8 deletions services/galley/src/Galley/API/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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
Expand Down
9 changes: 4 additions & 5 deletions services/galley/src/Galley/API/MLS/Removal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit acf5d67

Please sign in to comment.