You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 90dff9a
Browse filesBrowse the repository at this point in the historyBrowse files
feat(agency): multi-site per user + site picker + M:N social-binding spec
Migration 20260516000000_lx_site_multi.sql:
- Drop unique(user_id) on lx_site. Users can now own multiple sites.
- Add lx_site.name (defaults to domain) so the picker shows
"Acme Client" instead of "acme-corp.com" when the user renames.
- Add lx_site_user_idx for the agency dashboard.
Site picker UX:
- lib/lx/currentSite.ts — getCurrentSite() / listUserSites() /
setCurrentSite() helpers. getCurrentSite reads a current_site_id
cookie, validates the signed-in user owns the row, falls back to
the user's first site when the cookie is missing or stale.
- app/(app)/site-picker.tsx — dropdown in the nav. Single-site
users see a 1-item picker (useful because the "+ New site" entry
is reachable from the same control). 2+ sites flip it into a
real picker.
- app/actions/currentSite.ts — switchSite() server action that
verifies ownership before writing the cookie.
Site-scoped routes (everywhere we previously did
.eq("user_id", user.id).maybeSingle() to fetch "the user's site"):
- /autoblog (dashboard)
- /autoblog/setup (form, with ?new=1 flag for the "+ New site" flow)
- /autoblog/history
- createOrUpdateSite() server action — takes optional siteId; new
creates auto-set current_site_id so onboarding lands on the new site.
- rotateWebhookSecret() / setSitePaused() — operate on current site.
- /api/lx/sitemap/refresh, /api/lx/keywords/refresh,
/api/lx/articles/generate — all read the current-site cookie.
Social-posting PRD revision:
Restructured sp_account to be user-scoped (one pool per user, agencies
reuse "Acme LinkedIn" across multiple sites) and added a junction
table sp_site_account with:
- auto:bool — gate AI auto-generation per (site, account)
- render_overrides:jsonb — per-site rendering knob overrides
- enabled:bool — disable a binding without deleting it
§6 now describes the auto-mode pipeline: a site publishes → one
sp_post per auto=true binding, per-platform-rendered.
Tests + typecheck + build all green. Migration applied to prod.
0 commit comments