Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip pending proposals included in external commit #3107

Merged
merged 3 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion changelog.d/2-features/subconv-leave
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Implement endpoint for leaving a subconversation (#2969, #3080, #3085)
Implement endpoint for leaving a subconversation (#2969, #3080, #3085, #3107)
5 changes: 4 additions & 1 deletion services/galley/src/Galley/API/MLS/Message.hs
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,10 @@ processExternalCommit qusr mSenderClient lConvOrSub epoch action updatePath =
lConvOrSub' <- for lConvOrSub incrementEpoch

-- fetch backend remove proposals of the previous epoch
kpRefs <- getPendingBackendRemoveProposals (cnvmlsGroupId . mlsMetaConvOrSub . tUnqualified $ lConvOrSub') epoch
kpRefs <-
-- skip remove proposals of already removed by the external commit
filter (maybe (const True) (/=) remRef)
<$> getPendingBackendRemoveProposals (cnvmlsGroupId . mlsMetaConvOrSub . tUnqualified $ lConvOrSub') epoch
-- requeue backend remove proposals for the current epoch
let cm = membersConvOrSub (tUnqualified lConvOrSub')
createAndSendRemoveProposals lConvOrSub' kpRefs qusr cm
Expand Down
31 changes: 31 additions & 0 deletions services/galley/test/integration/API/MLS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ tests s =
[ test s "get subconversation of MLS conv - 200" (testCreateSubConv True),
test s "get subconversation of Proteus conv - 404" (testCreateSubConv False),
test s "join subconversation with an external commit bundle" testJoinSubConv,
test s "rejoin a subconversation with the same client" testExternalCommitSameClientSubConv,
test s "join subconversation with a client that is not in the parent conv" testJoinSubNonMemberClient,
test s "fail to add another client to a subconversation via internal commit" testAddClientSubConvFailure,
test s "remove another client from a subconversation" testRemoveClientSubConv,
Expand Down Expand Up @@ -2333,6 +2334,36 @@ testJoinSubConv = do
createExternalCommit alice1 Nothing (fmap (flip SubConv subId) qcnv)
>>= sendAndConsumeCommitBundle

testExternalCommitSameClientSubConv :: TestM ()
testExternalCommitSameClientSubConv = do
[alice, bob] <- createAndConnectUsers (replicate 2 Nothing)

runMLSTest $ do
[alice1, bob1] <- traverse createMLSClient [alice, bob]
void $ uploadNewKeyPackage bob1
(_, qcnv) <- setupMLSGroup alice1
void $ createAddCommit alice1 [bob] >>= sendAndConsumeCommitBundle

let subId = SubConvId "conference"

-- alice1 and bob1 create and join a subconversation, respectively
qsub <- createSubConv qcnv alice1 subId
void $
createExternalCommit bob1 Nothing qsub
>>= sendAndConsumeCommitBundle

Just (_, kpBob1) <- find (\(ci, _) -> ci == bob1) <$> getClientsFromGroupState alice1 bob

-- bob1 leaves and immediately rejoins
mlsBracket [alice1, bob1] $ \[wsA, wsB] -> do
void $ leaveCurrentConv bob1 qsub
WS.assertMatchN_ (5 # WS.Second) [wsA] $
wsAssertBackendRemoveProposal bob qsub kpBob1
void $
createExternalCommit bob1 Nothing qsub
>>= sendAndConsumeCommitBundle
WS.assertNoEvent (2 # WS.Second) [wsB]

testJoinSubNonMemberClient :: TestM ()
testJoinSubNonMemberClient = do
[alice, bob] <- createAndConnectUsers [Nothing, Nothing]
Expand Down