feat(discord): implement auto-join for Discord guild and update scopes#64
feat(discord): implement auto-join for Discord guild and update scopes#64mergify[bot] merged 2 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughAdded Discord guild auto-join on OAuth callback, persisted per-user join status, expanded OAuth scope to request Changes
Sequence Diagram(s)sequenceDiagram
participant Browser as Browser
participant OAuth as Discord OAuth
participant Callback as App Callback
participant DB as Database (Prisma)
participant DiscordAPI as Discord Guild API
participant Settings as Settings Page
Browser->>OAuth: Request auth (scope: identify guilds.join)
OAuth->>Browser: Redirect with code
Browser->>Callback: GET /callback?code=...
Callback->>Callback: Exchange code for token
Callback->>DB: Update user with Discord linkage
Callback->>DiscordAPI: PUT /guilds/{guild.id}/members (user token) [5s timeout]
alt Discord join succeeds
DiscordAPI->>Callback: 201/204 OK
Callback->>DB: Set discordJoinStatus = "joined"
Callback->>Browser: Redirect -> linked
else Discord join fails
DiscordAPI->>Callback: Error / missing config
Callback->>DB: Set discordJoinStatus = "failed"
Callback->>Browser: Redirect -> linked_join_failed
Browser->>Settings: PATCH /api/user/discord { joinStatus: "failed" } then revalidate
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
client/app/settings/page.tsx (1)
90-94: Persist guild-join outcome if this warning should remain visible after refresh.Lines 90-94 show a warning and call
mutate("/api/user/discord"), butclient/app/api/user/discord/route.ts(Lines 15-30) only returns link metadata, not guild-join status. The warning becomes non-representable after navigation/reload. Consider storing and returning a durable join-state field.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@client/app/settings/page.tsx` around lines 90 - 94, The warning for "linked_join_failed" is ephemeral because mutate("/api/user/discord") only returns link metadata; persist a durable join-state (e.g., joinStatus) on the user record and surface it from the GET handler in client/app/api/user/discord/route.ts so UI can represent the outcome after reload; when you detect status === "linked_join_failed" in the settings page, call an API mutation (or PATCH/POST endpoint) to set joinStatus = "failed" for that user and then call mutate("/api/user/discord") so the returned payload includes the new joinStatus and the warning can be re-rendered consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@client/app/api/user/discord/callback/route.ts`:
- Around line 25-55: The addUserToDiscordGuild function currently performs fetch
without timeout or local error handling; update it to create an AbortController,
set a timeout (e.g., 5s) that calls controller.abort(), pass controller.signal
into fetch, and wrap the fetch/response handling in a try-catch so any thrown
error or abort is caught locally; on error or non-OK/non-201/204 responses
return false (and log the error with details) so the caller can set
linked_join_failed rather than letting the exception bubble as internal_error;
also clear the timeout timer on success or failure to avoid leaks.
---
Nitpick comments:
In `@client/app/settings/page.tsx`:
- Around line 90-94: The warning for "linked_join_failed" is ephemeral because
mutate("/api/user/discord") only returns link metadata; persist a durable
join-state (e.g., joinStatus) on the user record and surface it from the GET
handler in client/app/api/user/discord/route.ts so UI can represent the outcome
after reload; when you detect status === "linked_join_failed" in the settings
page, call an API mutation (or PATCH/POST endpoint) to set joinStatus = "failed"
for that user and then call mutate("/api/user/discord") so the returned payload
includes the new joinStatus and the warning can be re-rendered consistently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d56d7345-4fca-4e69-a1c9-596a37313d89
📒 Files selected for processing (3)
client/app/api/user/discord/callback/route.tsclient/app/api/user/discord/connect/route.tsclient/app/settings/page.tsx
|
@mergify queue |
Merge Queue Status
This pull request spent 6 seconds in the queue, with no time running CI. Required conditions to merge
|
Summary by CodeRabbit
New Features
Bug Fixes
Chores