Commit 9fd7e23
docs(swagger): add user_id query to three cache-priming endpoints (#839)
## Summary
Adds an optional `user_id` query parameter to three routes that embed
user objects in their response and rely on `app.getMyId(c)` to
personalize them. Today the SDK request types don't expose this field,
so clients never send `?user_id=` and the backend computes
personalization against `MyID = 0` — i.e. `does_current_user_follow` and
friends return false for every embedded user.
- `GET /events/remix-contests`
([v1_events_remix_contests.go:187,195,215](https://github.com/AudiusProject/api/blob/main/api/v1_events_remix_contests.go#L187))
- `GET /users/{id}/contests`
([v1_users_contests.go:114,122,142](https://github.com/AudiusProject/api/blob/main/api/v1_users_contests.go#L114))
- `GET /playlists/new-releases`
([v1_playlists_new_releases.go:74](https://github.com/AudiusProject/api/blob/main/api/v1_playlists_new_releases.go#L74))
## Why
Audit follow-up to [#837](#837)
/ [#838](#838) (notifications).
Same bug class:
1. Endpoint embeds users in `related.users` (or a collection's `user`
field).
2. Backend handler passes `MyID: app.getMyId(c)` into
`dbv1.ParallelParams` to personalize those users.
3. `getMyId(c)` reads from the query string `?user_id=`. With no query
value, `MyID = 0` and the SQL
[short-circuits](https://github.com/AudiusProject/api/blob/main/api/dbv1/get_users.sql.go#L129-L136)
`does_current_user_follow` to false.
4. Web/mobile prime those un-personalized users into a shared tan-query
cache (via `primeRelatedData` for remix-contests, `primeCollectionData`
→ `primeUserData` for new-releases). The cache write only happens when
the slot is empty, so once poisoned the entry sticks until the user
navigates to that profile and a personalized fetch overwrites it.
Affected client hooks:
- `useAllRemixContests`
([apps/packages/common/src/api/tan-query/events/useAllRemixContests.ts](https://github.com/AudiusProject/apps/blob/main/packages/common/src/api/tan-query/events/useAllRemixContests.ts))
- `useUserRemixContests`
([apps/packages/common/src/api/tan-query/events/useUserRemixContests.ts](https://github.com/AudiusProject/apps/blob/main/packages/common/src/api/tan-query/events/useUserRemixContests.ts))
- `useNewAlbumReleases`
([apps/packages/common/src/api/tan-query/collection/useNewAlbumReleases.ts](https://github.com/AudiusProject/apps/blob/main/packages/common/src/api/tan-query/collection/useNewAlbumReleases.ts))
## Spec-only change
`resolveMyIdMiddleware` already reads `c.Query(\"user_id\")` globally
([resolve_middleware.go:24-28](https://github.com/AudiusProject/api/blob/main/api/resolve_middleware.go#L24)),
so the Go handlers personalize correctly as soon as the SDK starts
sending the param. No backend code change required, no Go test updates
required.
No path-placeholder collision this time — all three routes are either
query-only (`new-releases`, `remix-contests`) or already use `id` as the
path placeholder (`users/{id}/contests`). The generator will emit a
clean `userId?: string` field.
## Test plan
- [ ] Spec validates in CI.
- [ ] After SDK regen + apps update (follow-up PR): on a fresh app load
with a signed-in account that follows artists surfaced on the Browse →
New Albums and Explore → Contests pages, confirm Following state renders
correctly without first having to visit each artist's profile.
- [ ] Network inspector on the three endpoints shows
`?user_id=<hashed-current-user-id>` and `does_current_user_follow: true`
for users actually followed in `related.users`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 4e763a9 commit 9fd7e23
1 file changed
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1232 | 1232 | | |
1233 | 1233 | | |
1234 | 1234 | | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
1235 | 1243 | | |
1236 | 1244 | | |
1237 | 1245 | | |
| |||
1785 | 1793 | | |
1786 | 1794 | | |
1787 | 1795 | | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
1788 | 1804 | | |
1789 | 1805 | | |
1790 | 1806 | | |
| |||
5580 | 5596 | | |
5581 | 5597 | | |
5582 | 5598 | | |
| 5599 | + | |
| 5600 | + | |
| 5601 | + | |
| 5602 | + | |
| 5603 | + | |
| 5604 | + | |
| 5605 | + | |
| 5606 | + | |
5583 | 5607 | | |
5584 | 5608 | | |
5585 | 5609 | | |
| |||
0 commit comments