diff --git a/services/galley/src/Galley/API/MLS/SubConversation.hs b/services/galley/src/Galley/API/MLS/SubConversation.hs index d22bad99d5e..a3c4538a4cb 100644 --- a/services/galley/src/Galley/API/MLS/SubConversation.hs +++ b/services/galley/src/Galley/API/MLS/SubConversation.hs @@ -288,7 +288,12 @@ deleteLocalSubConversation qusr lcnvId scnvId dsc = do let (gid, epoch) = (cnvmlsGroupId &&& cnvmlsEpoch) (scMLSData sconv) unless (dscGroupId dsc == gid) $ throwS @'ConvNotFound unless (dscEpoch dsc == epoch) $ throwS @'MLSStaleMessage + -- NOTE(md): check if this creates external proposals, but my hunch is it + -- doesn't as it shouldn't (there's no one to commit them once the subconv + -- is deleted). Eff.removeAllMLSClients gid + -- TODO(md): Make sure to call the 'deleteAllProposals gid' action to remove + -- all uncommitted proposals as it makes no sense to keep them around. newGid <- Eff.makeFreshGroupId diff --git a/services/galley/src/Galley/Cassandra/SubConversation.hs b/services/galley/src/Galley/Cassandra/SubConversation.hs index ad143121146..5847c1cf9fc 100644 --- a/services/galley/src/Galley/Cassandra/SubConversation.hs +++ b/services/galley/src/Galley/Cassandra/SubConversation.hs @@ -30,11 +30,15 @@ import Galley.API.MLS.Types (SubConversation (..)) import Galley.Cassandra.Conversation.MLS (lookupMLSClients) import qualified Galley.Cassandra.Queries as Cql import Galley.Cassandra.Store (embedClient) +import Galley.Effects.ProposalStore import Galley.Effects.SubConversationStore (SubConversationStore (..)) import Imports import Polysemy import Polysemy.Input +import qualified UnliftIO.Exception as UnliftIO import Wire.API.Conversation.Protocol +import Wire.API.Error +import Wire.API.Error.Galley import Wire.API.MLS.CipherSuite import Wire.API.MLS.Group import Wire.API.MLS.PublicGroupState @@ -103,7 +107,11 @@ listSubConversations cid = do ) interpretSubConversationStoreToCassandra :: - Members '[Embed IO, Input ClientState] r => + ( Member (Embed IO) r, + Member (ErrorS 'ConvNotFound) r, + Member (Input ClientState) r, + Member ProposalStore r + ) => Sem (SubConversationStore ': r) a -> Sem r a interpretSubConversationStoreToCassandra = interpret $ \case @@ -115,7 +123,17 @@ interpretSubConversationStoreToCassandra = interpret $ \case SetSubConversationEpoch cid sconv epoch -> embedClient $ setEpochForSubConversation cid sconv epoch DeleteGroupIdForSubConversation groupId -> embedClient $ deleteGroupId groupId ListSubConversations cid -> embedClient $ listSubConversations cid - DeleteSubConversation convId subConvId -> embedClient $ deleteSubConversation convId subConvId + DeleteSubConversation convId subConvId -> do + msub <- embedClient (selectSubConversation convId subConvId) + case msub of + Nothing -> do + let e = toWai @GalleyError 'ConvNotFound + -- TODO(md): finish throwing the error + mapToRuntimeError $ throwS @'ConvNotFound + embed @IO $ UnliftIO.throwIO e + Just sub -> do + deleteAllProposals . cnvmlsGroupId . scMLSData $ sub + embedClient $ deleteSubConversation convId subConvId -------------------------------------------------------------------------------- -- Utilities