Skip to content

Commit

Permalink
WIP: Application code TODOs and notes
Browse files Browse the repository at this point in the history
  • Loading branch information
mdimjasevic committed Mar 6, 2023
1 parent 3b90299 commit 20be258
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions services/galley/src/Galley/API/MLS/SubConversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 20 additions & 2 deletions services/galley/src/Galley/Cassandra/SubConversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 20be258

Please sign in to comment.