Skip to content

Commit

Permalink
Simplify processProposal arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti committed Apr 28, 2023
1 parent c8f9327 commit 7f2ae5c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libs/wire-api/src/Wire/API/MLS/CommitBundle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Wire.API.MLS.Serialisation
import Wire.API.MLS.Welcome

data CommitBundle = CommitBundle
{ commitMsg :: RawMLS Message, -- TODO: change this type to Commit
{ commitMsg :: RawMLS Message,
welcome :: Maybe (RawMLS Welcome),
groupInfo :: RawMLS GroupInfo
}
Expand Down
4 changes: 2 additions & 2 deletions services/galley/src/Galley/API/MLS/Message.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ import Wire.API.MLS.Serialisation
import Wire.API.MLS.SubConversation

-- TODO:
-- [ ] replace commit message in CommitBundle with a Commit object
-- [ ] restore deleted MLS unit tests
-- [ ] pass groupId and epoch to processProposal instead of the whole IncomingMessage
-- [ ] remove LWT in planMLSClientRemoval
-- [ ] restore unsupported proposal integration test

-- FUTUREWORK
-- - Check that the capabilities of a leaf node in an add proposal contains all
Expand Down Expand Up @@ -354,7 +354,7 @@ postMLSMessageToLocalConv qusr c con msg convOrSubId = do
FramedContentCommit _commit -> throwS @'MLSUnsupportedMessage
FramedContentApplicationData _ -> throwS @'MLSUnsupportedMessage
FramedContentProposal prop ->
processProposal qusr lConvOrSub msg pub prop $> mempty
processProposal qusr lConvOrSub msg.groupId msg.epoch pub prop $> mempty
IncomingMessageContentPrivate -> pure mempty

let cm = membersConvOrSub (tUnqualified lConvOrSub)
Expand Down
11 changes: 6 additions & 5 deletions services/galley/src/Galley/API/MLS/Proposal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -245,24 +245,25 @@ processProposal ::
) =>
Qualified UserId ->
Local ConvOrSubConv ->
IncomingMessage -> -- TODO: just pass header?
GroupId ->
Epoch ->
IncomingPublicMessageContent ->
RawMLS Proposal ->
Sem r ()
processProposal qusr lConvOrSub msg pub prop = do
processProposal qusr lConvOrSub groupId epoch pub prop = do
let mlsMeta = mlsMetaConvOrSub (tUnqualified lConvOrSub)
-- Check if the epoch number matches that of a conversation
unless (msg.epoch == cnvmlsEpoch mlsMeta) $ throwS @'MLSStaleMessage
unless (epoch == cnvmlsEpoch mlsMeta) $ throwS @'MLSStaleMessage
-- Check if the group ID matches that of a conversation
unless (msg.groupId == cnvmlsGroupId mlsMeta) $ throwS @'ConvNotFound
unless (groupId == cnvmlsGroupId mlsMeta) $ throwS @'ConvNotFound
let suiteTag = cnvmlsCipherSuite mlsMeta

-- FUTUREWORK: validate the member's conversation role
let im = indexMapConvOrSub $ tUnqualified lConvOrSub
checkProposal mlsMeta im prop.value
when (isExternal pub.sender) $ checkExternalProposalUser qusr prop.value
let propRef = authContentRef suiteTag (incomingMessageAuthenticatedContent pub)
storeProposal msg.groupId msg.epoch propRef ProposalOriginClient prop
storeProposal groupId epoch propRef ProposalOriginClient prop

getKeyPackageIdentity ::
Member (ErrorS 'MLSUnsupportedProposal) r =>
Expand Down

0 comments on commit 7f2ae5c

Please sign in to comment.