core: fix member version range not being correctly updated in some cases (fixes introducing owner to member in review, when host admin was invited via owner's link; likely fixes other interactions that check version) (#6208)

* core: fix introducing owner to member in review

* fix

* remove diff

* unfocus

* plans
This commit is contained in:
spaced4ndy
2025-08-20 11:00:11 +00:00
committed by GitHub
parent 6941539f25
commit 0046fc27fe
3 changed files with 113 additions and 2 deletions

View File

@@ -1326,9 +1326,9 @@ updatePeerChatVRange conn@Connection {connId, connChatVersion = v, peerChatVRang
else pure conn'
updateMemberChatVRange :: GroupMember -> Connection -> VersionRangeChat -> CM (GroupMember, Connection)
updateMemberChatVRange mem@GroupMember {groupMemberId} conn@Connection {connId, connChatVersion = v, peerChatVRange} msgVRange = do
updateMemberChatVRange mem@GroupMember {groupMemberId, memberChatVRange} conn@Connection {connId, connChatVersion = v, peerChatVRange} msgVRange = do
v' <- lift $ upgradedConnVersion v msgVRange
if msgVRange /= peerChatVRange || v' /= v
if msgVRange /= peerChatVRange || v' /= v || msgVRange /= memberChatVRange
then do
withStore' $ \db -> do
setPeerChatVRange db connId v' msgVRange

View File

@@ -4552,6 +4552,14 @@ Query:
Plan:
SEARCH group_members USING INTEGER PRIMARY KEY (rowid=?)
Query:
UPDATE group_members
SET peer_chat_min_version = ?, peer_chat_max_version = ?
WHERE group_member_id = ?
Plan:
SEARCH group_members USING INTEGER PRIMARY KEY (rowid=?)
Query:
UPDATE group_members
SET show_messages = ?, updated_at = ?

View File

@@ -112,6 +112,7 @@ chatGroupTests = do
it "accept member - only moderators review" testGLinkReviewMember
it "accept member - host approval, then moderators review" testGLinkApproveThenReviewMember
it "delete pending approval member" testGLinkDeletePendingApprovalMember
it "admin that joined via link introduces member for moderator review" testGLinkReviewIntroduce
describe "group link connection plan" $ do
it "ok to connect; known group" testPlanGroupLinkKnown
it "own group link" testPlanGroupLinkOwn
@@ -3392,6 +3393,108 @@ testGLinkDeletePendingApprovalMember =
where
cfg = testCfg {chatHooks = defaultChatHooks {acceptMember = Just (\_ _ _ -> pure $ Right (GAPendingApproval, GRObserver))}}
testGLinkReviewIntroduce :: HasCallStack => TestParams -> IO ()
testGLinkReviewIntroduce =
testChat5 aliceProfile bobProfile cathProfile danProfile eveProfile $
\alice bob cath dan eve -> do
createGroup3' "team" alice (bob, GRMember) (cath, GRModerator)
alice ##> "/create link #team"
gLink <- getGroupLink alice "team" GRMember True
dan ##> ("/c " <> gLink)
dan <## "connection request sent!"
alice <## "dan (Daniel): accepting request to join group #team..."
concurrentlyN_
[ alice <## "#team: dan joined the group",
do
dan <## "#team: joining the group..."
dan <## "#team: you joined the group"
dan <###
[ "#team: member bob (Bob) is connected",
"#team: member cath (Catherine) is connected"
],
do
bob <## "#team: alice added dan (Daniel) to the group (connecting...)"
bob <## "#team: new member dan is connected",
do
cath <## "#team: alice added dan (Daniel) to the group (connecting...)"
cath <## "#team: new member dan is connected"
]
alice ##> "/mr team dan admin"
concurrentlyN_
[ alice <## "#team: you changed the role of dan to admin",
bob <## "#team: alice changed the role of dan from member to admin",
cath <## "#team: alice changed the role of dan from member to admin",
dan <## "#team: alice changed your role from member to admin"
]
alice ##> "/set admission review #team all"
alice <## "changed member admission rules"
concurrentlyN_
[ do
bob <## "alice updated group #team:"
bob <## "changed member admission rules",
do
cath <## "alice updated group #team:"
cath <## "changed member admission rules",
do
dan <## "alice updated group #team:"
dan <## "changed member admission rules"
]
dan ##> "/create link #team"
gLinkDan <- getGroupLink dan "team" GRMember True
eve ##> ("/c " <> gLinkDan)
eve <## "connection request sent!"
dan <## "eve (Eve): accepting request to join group #team..."
concurrentlyN_
[ dan <## "#team: eve connected and pending review",
eve
<### [ "#team: dan accepted you to the group, pending review",
"#team: joining the group...",
"#team: you joined the group, connecting to group moderators for admission to group",
"#team: member alice (Alice) is connected",
"#team: member cath (Catherine) is connected"
],
do
alice <## "#team: dan added eve (Eve) to the group (connecting and pending review...), use /_accept member #1 5 <role> to accept member"
alice <## "#team: new member eve is connected and pending review, use /_accept member #1 5 <role> to accept member",
do
cath <## "#team: dan added eve (Eve) to the group (connecting and pending review...), use /_accept member #1 5 <role> to accept member"
cath <## "#team: new member eve is connected and pending review, use /_accept member #1 5 <role> to accept member"
]
-- owner accepts new member
alice ##> "/_accept member #1 5 member"
concurrentlyN_
[ alice <## "#team: eve accepted",
dan <## "#team: alice accepted eve to the group (will introduce remaining members)",
cath <## "#team: alice accepted eve to the group",
eve
<### [ "#team: you joined the group",
"#team: member bob (Bob) is connected"
],
do
bob <## "#team: dan added eve (Eve) to the group (connecting...)"
bob <## "#team: new member eve is connected"
]
alice #> "#team 1"
[bob, cath, dan, eve] *<# "#team alice> 1"
bob #> "#team 2"
[alice, cath, dan, eve] *<# "#team bob> 2"
cath #> "#team 3"
[alice, bob, dan, eve] *<# "#team cath> 3"
dan #> "#team 4"
[alice, bob, cath, eve] *<# "#team dan> 4"
eve #> "#team 5"
[alice, bob, cath, dan] *<# "#team eve> 5"
testPlanGroupLinkKnown :: HasCallStack => TestParams -> IO ()
testPlanGroupLinkKnown =
testChat2 aliceProfile bobProfile $