fix: go-live audit — Gmail/Outlook import, scope bugs, sidebar 404s, auth refresh #4047
Cross-repo impact
See what breaks downstream if this PR merges.
⮌ Merged
This pull request was merged into main.
c comment · e edit title · m merge · a approve · r request changes · ? shortcuts
Originally written by @ccantynz-alt on GitHub.
Imported from https://github.com/ccantynz-alt/AlecRae.com/pull/84
Summary
Full go-live audit with 5 concrete fixes + MTA documentation for port-25 direct delivery.
What was broken and is now fixed
1. Gmail/Outlook history backfill was completely broken (
routes/import.ts)startGmailImportandstartOutlookImportimmediately set job status tofailedwith a "not available" messagesyncGmailMessages/syncOutlookMessagesfrom the real sync engine, and update job progress with actual results (up to 2000 messages)2. Scope mismatch blocked IMAP connect/disconnect/list/sync (
routes/connect.ts)requireScope("accounts:write")andrequireScope("accounts:read")(with 's') — scopes thatscopesForRole()injwt.tsnever issuedaccount:manageandaccount:read(no 's') → every IMAP route 403'daccount:manage/account:read3. Two sidebar links 404'd (
layout.tsx)/delegation→ no page exists (delegation is a tab inside/shared-inboxes)/developer→ page lives at/settings/developer4. Auth token refresh missing on
agentandnotificationspagesapiFetchthat read the token once without 401→refresh→retry logicrefreshSession()+ retry pattern fromauth-token.ts5. Gmail/Outlook import UI added to Workspace → Import tab (
workspace/page.tsx,api.ts)connectApi.listAccounts()loads connected Gmail/Outlook accounts on mount; "Import now" button per account triggersPOST /v1/import/gmailor/outlook;importApi.gmail()+importApi.outlook()added toapi.ts6. MTA runbook updated for port-25 direct delivery (
docs/infra/mta-box-setup.md)alecrae-mtasystemd service still needs to be created on the box by CraigCraig's remaining tasks to go live with email
docs/infra/mta-box-setup.md149.28.119.158→mail.alecrae.comin Vultr control panel. Start MTA with noRELAY_PROVIDERenv.alecrae.comin Resend dashboard + setRELAY_PROVIDER=smtp+SMTP_RELAY_*vars in.envTest plan
🤖 Generated with Claude Code
https://claude.ai/code/session_01GYakKc6rtYKmTgknsK1AiY
Generated by Claude Code