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
+4 -1
View File
@@ -140,7 +140,10 @@ createUserRecordAt db (AgentUserId auId) userChatRelay clientService Profile {di
sendRcptsContacts = True
sendRcptsSmallGroups = True
autoAcceptMemberContacts = False
order <- getNextActiveOrder db
-- active_order means "last activated", and setActiveUser is otherwise its only
-- writer - so a user created without being activated must not consume an order,
-- or it would sort above the profile that is actually in use.
order <- if activeUser then getNextActiveOrder db else pure 0
DB.execute
db
"INSERT INTO users (agent_user_id, local_display_name, active_user, is_user_chat_relay, active_order, contact_id, show_ntfs, send_rcpts_contacts, send_rcpts_small_groups, auto_accept_member_contacts, client_service, created_at, updated_at) VALUES (?,?,?,?,?,0,?,?,?,?,?,?,?)"