-
Notifications
You must be signed in to change notification settings - Fork 20
feat: implement structured feedback modal and integrate feedback service #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4cb5103
feat: implement structured feedback modal and integrate feedback service
ToxicBiohazard e6f8a47
fix: fall back to Slack when feedback service ingest fails
ToxicBiohazard 391426e
Merge branch 'main' into TECHOPS-247-hackster-discord-feedback
ToxicBiohazard 63c386e
Potential fix for pull request finding
ToxicBiohazard 78a20e9
Potential fix for pull request finding
ToxicBiohazard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| """Feedback form choices aligned with the feedback service ingest schema.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from discord import OptionChoice | ||
|
|
||
| # (display label, ingest slug) — matches feedback service FeedbackKind | ||
| FEEDBACK_KINDS: list[tuple[str, str]] = [ | ||
| ("Bug report", "bug"), | ||
| ("Feature request", "product_feature"), | ||
| ("Suggestion", "suggestion"), | ||
| ("Comment", "comment"), | ||
| ("Review", "review"), | ||
| ("Other", "other"), | ||
| ] | ||
|
|
||
| # (display label, ingest slug) — matches feedback service HTBPlatform catalog | ||
| FEEDBACK_PLATFORMS: list[tuple[str, str]] = [ | ||
| ("HTB Labs", "htb_labs"), | ||
| ("HTB Academy", "htb_academy"), | ||
| ("HTB Enterprise", "htb_enterprise"), | ||
| ("HTB CTF", "htb_ctf"), | ||
| ("HTB Discord", "htb_discord"), | ||
| ("HTB Account", "htb_account"), | ||
| ("HTB Profile", "htb_profile"), | ||
| ("HTB Website", "htb_landing_website"), | ||
| ("Other", "other"), | ||
| ] | ||
|
|
||
| FEEDBACK_KIND_VALUES = [value for _, value in FEEDBACK_KINDS] | ||
| FEEDBACK_PLATFORM_VALUES = [value for _, value in FEEDBACK_PLATFORMS] | ||
|
|
||
|
|
||
| def feedback_kind_choices() -> list[OptionChoice]: | ||
| return [OptionChoice(label, value) for label, value in FEEDBACK_KINDS] | ||
|
|
||
|
|
||
| def feedback_platform_choices() -> list[OptionChoice]: | ||
| return [OptionChoice(label, value) for label, value in FEEDBACK_PLATFORMS] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| """Send Discord feedback to the feedback service ingest API.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| from typing import Any | ||
|
|
||
| import aiohttp | ||
|
|
||
| from src.core import settings | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def is_configured() -> bool: | ||
| """Return True when feedback service URL and API key are both set.""" | ||
| return bool(settings.FEEDBACK_SERVICE_URL and settings.FEEDBACK_SERVICE_API_KEY) | ||
|
|
||
|
|
||
| async def ingest_discord_feedback(payload: dict[str, Any]) -> bool: | ||
| """POST a payload to the feedback service /api/ingest/discord endpoint. | ||
|
|
||
| Returns True when the service accepts the payload (HTTP 202). | ||
| """ | ||
| if not is_configured(): | ||
| return False | ||
|
|
||
| headers = {"Authorization": f"Bearer {settings.FEEDBACK_SERVICE_API_KEY}"} | ||
| async with aiohttp.ClientSession() as session: | ||
| try: | ||
| async with session.post( | ||
| settings.FEEDBACK_SERVICE_URL, | ||
| json=payload, | ||
| headers=headers, | ||
| timeout=aiohttp.ClientTimeout(total=15), | ||
| ) as response: | ||
| if response.status == 202: | ||
| return True | ||
| body = await response.text() | ||
| logger.error( | ||
| "Feedback service ingest failed: %s - %s", | ||
| response.status, | ||
| body[:500], | ||
| ) | ||
| return False | ||
| except Exception: | ||
| logger.exception("Feedback service ingest request failed") | ||
| return False |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.