Skip to content

Account routes: /accounts/{username} public profile; drop company_name#154

Merged
martsokha merged 1 commit into
mainfrom
refactor/account-route-vocab
Jul 19, 2026
Merged

Account routes: /accounts/{username} public profile; drop company_name#154
martsokha merged 1 commit into
mainfrom
refactor/account-route-vocab

Conversation

@martsokha

Copy link
Copy Markdown
Member

Summary

Resolves the account-route inconsistency (PATCH /account/ vs GET /u/{username}/ used two different nouns for one resource) and removes the unused company_name field.

Account vocabulary

Researched GitHub's model (cited): it keeps two shapes — an identifier-less self route (/user, resolved from the token, richer representation) and a named-other route (/users/{login}, public representation) — and never mutates a user via /users/{name}. The two shapes are intentional; only the noun should be unified.

  • Rename /u/{username}//accounts/{username}/, so the account resource uses one noun: /account/ (self) + /accounts/{username}/ (others). No more /u/ shorthand.
  • Cross-account lookups now return a trimmed PublicAccount (username, display name, created_at) instead of the full account — email and account flags (isAdmin/isSuspended/isActivated) are available only through the caller's own /account/ view. This matches GitHub's public-vs-self representation split.
  • Access is still gated by a shared workspace, returning 404 (not 403) when none is shared, so the endpoint can't be used to enumerate handles.

Remove company_name

Deleted the field end to end: accounts column + length constraint + comment, schema.rs, Account/NewAccount/UpdateAccount models and the has_company helper, the CompanyNameLengthMax constraint enum arm and its error mapping, the create/update normalization, and the request/response DTOs.

Verification

  • Full gate green: check / clippy -D warnings / nightly fmt / rustdoc -D warnings / test (13 suites). Migrations reset+reapplied; schema.rs regenerated.
  • Live E2E: /account/ returns the full self view (with email, no company); /accounts/{username}/ returns the trimmed public view (no email/company/flags); old /u/{username}/ → 404; peer with no shared workspace → 404; unknown handle → 404. OpenAPI spec confirmed: 0 companyName, /accounts/{username}/ present, /u/{username}/ gone.

🤖 Generated with Claude Code

- Rename the profile route /u/{username} -> /accounts/{username}, unifying the
  account vocabulary (self at /account/, others at /accounts/{username}), mirroring
  GitHub's /user + /users/{login} split.
- Return a trimmed PublicAccount (username, display name, created_at) for
  cross-account lookups; email and account flags stay in the caller's own
  /account/ view only. Access remains gated by a shared workspace (404 otherwise).
- Remove company_name entirely: column + constraint, model/query, request/response,
  and the accounts constraint enum arm.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@martsokha martsokha added refactor code restructuring without behavior change server API handlers, middleware, auth postgres ORM, models, queries, migrations labels Jul 19, 2026
@martsokha martsokha self-assigned this Jul 19, 2026
@martsokha
martsokha merged commit 5545f2a into main Jul 19, 2026
7 checks passed
@martsokha
martsokha deleted the refactor/account-route-vocab branch July 19, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

postgres ORM, models, queries, migrations refactor code restructuring without behavior change server API handlers, middleware, auth

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant