core: don't consume an active order for a user created without activating it

createUserRecordAt gates the "UPDATE users SET active_user = 0" on the activeUser
argument but called getNextActiveOrder unconditionally, so a profile created with
keepActiveUser got active_order = max + 1 despite never having been active. Every
picker sorts on that column descending, so the new profile sorted above the profile
actually in use - in the Android user picker, which sorts the full list, literally
above the active one.

active_order means "last activated" and setActiveUser is otherwise its only writer,
so a profile that was never activated now keeps 0 and sorts last until it is used.

Also asserts in the test that the created user's own record is not active: /u only
covers the currentUser TVar, and it is the user record that the clients branch on to
detect a core that ignored the flag. Moves the second test to "user profiles", which
is what it tests - it has nothing to do with short links.
This commit is contained in:
Narasimha-sc
2026-08-06 13:34:37 +00:00
parent 323609a60f
commit fec195fe7b
2 changed files with 10 additions and 2 deletions
+6 -1
View File
@@ -52,6 +52,7 @@ chatProfileTests = do
it "reject profile image that is too large" testSetProfileImageTooLarge
it "set profile image from file" testSetProfileImageFromFile
it "use multiword profile names" testMultiWordProfileNames
it "create user without keepActiveUser activates it" testCreateUserWithoutKeepActiveUser
it "present supporter badge to contacts" testUserBadgeBroadcast
it "supporter badge sent to contact connecting after attach" testUserBadgeOnConnect
it "supporter badge sent to member joining via group link" testUserBadgeGroupLink
@@ -154,7 +155,6 @@ shortLinkTests = do
it "change prepared contact user" testShortLinkChangePreparedContactUser
it "change prepared contact user, new user has contact with the same name" testShortLinkChangePreparedContactUserDuplicate
it "create user keeping active user, then change prepared contact user" testCreateUserKeepingActiveUser
it "create user without keepActiveUser activates it" testCreateUserWithoutKeepActiveUser
it "connect to prepared group incognito" testShortLinkConnectPreparedGroupIncognito
it "change prepared group user" testShortLinkChangePreparedGroupUser
it "change prepared group user, new user has group with the same name" testShortLinkChangePreparedGroupUserDuplicate
@@ -4005,6 +4005,11 @@ testCreateUserKeepingActiveUser = testChat2 aliceProfile bobProfile test
-- ... and the active user is unchanged, with no switch back needed
bob ##> "/u"
showActiveUser bob "bob (Bob)"
-- the new user's own record is not active either - the clients branch on this
-- field of the created user, and it is listed last, having never been activated
bob ##> "/users"
bob <## "bob (Bob) (active)"
bob <## "robert"
alice ##> "/_connect 1"
(shortLink, fullLink) <- getInvitations alice