user

package
v1.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package user holds account predicates for callers that must not import modules/user.

Same reason pkg/space exists: modules/user imports half the tree, so a predicate package that only needs a *dbr.Session belongs outside it. This package depends on dbr and nothing else.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveAccounts

func ActiveAccounts(session dbr.SessionRunner, uids []string) (map[string]bool, error)

ActiveAccounts returns the subset of uids whose ACCOUNT is still live, keyed by the spelling the database holds.

The predicate, and why both columns

status = 1 AND is_destroy <> 2

This is the repository's canonical "account still occupies its identity" gate — modules/user.BuildBatchUsersResponse applies exactly this pair, and its comment explains the half that is easy to get wrong: a COOLING-OFF account (is_destroy = 1, a reversible destroy request) can still send and receive, so it is live and must stay in the answer. Only the terminal is_destroy = 2 counts as gone. Gating on status alone would surface a fully destroyed account mid-teardown, since teardown can leave status = 1 for a while.

Why this is a SEPARATE query rather than a JOIN

Callers hold rows from tables that may be in a different collation. `user` is one of the dump-imported tables that inherited utf8mb4_0900_ai_ci in production, while migration-created tables declare utf8mb4_general_ci — so `... JOIN user u ON u.uid = pm.uid` is MySQL error 1267 THERE while passing in CI, whose database is created general_ci. Measured on 8.0: the JOIN form errors, this single-table form does not.

A JOIN rooted at a legacy table (space_member ⋈ user ⋈ space) is safe, because all three sides drifted together — the two existing precedents (modules/user.authVerifyAPIKey, modules/bot_provision.assertSpaceMember) have that shape. Callers rooted at an octo_* table must use this function instead.

Keyed by the DATABASE's spelling

`uid` compares case-insensitively under either collation, so a row can come back spelled differently from the uid that was asked for. Callers that need to match their own strings fold both sides — see pkg/project.FoldID, which is what its two batch readers do.

Absent from the map means "not a live account"; the map is never nil on success.

Like pkg/space.ActiveMembers this takes a dbr.SessionRunner: passed a *dbr.Session it runs outside any caller transaction and proves nothing about state at COMMIT time, and passed a *dbr.Tx it joins that transaction's snapshot. pkg/project.ProjectMemberships passes a *dbr.Tx on purpose — see the note there — so a caller in that position must not be "simplified" back to the session.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址