fix: guard Discord role apply on unlinked contacts#199
fix: guard Discord role apply on unlinked contacts#199michaelmwu wants to merge 1 commit intomainfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Pull request overview
This PR guards Discord role application against contacts that are not linked to a Discord user. It prevents the "Apply Discord Roles" flow from being triggered when no Discord link exists, surfacing the missing-link status to the user both in the embed and via a disabled button.
Changes:
ResumeApplyDiscordRolesButtonnow accepts adisabledparameter and a new server-side guard in its callback rejects the action whencan_apply_discord_rolesisFalse.ResumeUpdateConfirmationViewreceives and stores a newcan_apply_discord_roles: boolfield, used to initialize the apply button's disabled state._run_resume_extract_and_previewcomputescan_apply_discord_rolesbased on whether a Discord user ID or linked member is available, and passes it to both the embed builder and the view.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def __init__(self, *, disabled: bool = False) -> None: | ||
| super().__init__( | ||
| label="Apply Discord Roles", | ||
| style=discord.ButtonStyle.success, | ||
| custom_id="resume_apply_discord_roles", | ||
| disabled=disabled, | ||
| ) |
There was a problem hiding this comment.
In ResumeEditDiscordRolesModal.on_submit (line 1026, outside the diff), the apply button's disabled state is recomputed as not bool(normalized), which ignores can_apply_discord_roles. If a user with an unlinked contact opens and saves the Edit Discord Roles modal with at least one role, the button will be visually re-enabled even though it was intentionally disabled due to no Discord link. The disabled computation there should also check confirmation_view.can_apply_discord_roles, e.g. not bool(normalized) or not self.confirmation_view.can_apply_discord_roles. Although the server-side guard at line 1288 still protects against the action being carried out, the UI state becomes inconsistent with the intent of this PR.
Description
Prevented resume-driven Discord role application when a contact is not linked to a Discord user.
The Suggested Discord Roles embed now clearly explains that role application is blocked when linking is missing.
The Apply Discord Roles button is now disabled unless a linked Discord user is available.
The apply callback also hard-fails with an explicit user-facing message if triggered while unlinked.
Linkability is now passed through the resume extraction flow so UI and runtime behavior stay consistent.
Related Issue
N/A
How Has This Been Tested?
Ran project pre-commit hooks and verified the diff against
origin/main.