Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .test.env
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@ HTB_API_KEY=CHANGE_ME
#Feedback Webhook
SLACK_FEEDBACK_WEBHOOK="https://hook.slack.com/sdfsdfsf"

#Feedback Webhook
# Webhook
JIRA_WEBHOOK="https://automation.atlassian.com/sdfsdfsf"
JIRA_WEBHOOK_SECRET=xxxxxxxxxxxxx
16 changes: 12 additions & 4 deletions src/cmds/core/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ async def callback(self, interaction: discord.Interaction) -> None:
"type": "spoiler"
}

await webhook.webhook_call(webhook_url, data)
headers = {
"X-Automation-Webhook-Token": settings.JIRA_WEBHOOK_SECRET,
}

await webhook.webhook_call(webhook_url, data, headers)


class SpoilerConfirmationView(View):
Expand Down Expand Up @@ -133,7 +137,7 @@ async def no_hints(self, ctx: ApplicationContext) -> Message:
)

@slash_command(guild_ids=settings.guild_ids,
description="A simple reply proving a link to the support desk article on how to get support")
description="A simple reply providing a link to the support desk article on how to get support")
@commands.cooldown(1, 60, commands.BucketType.user)
async def support(
self, ctx: ApplicationContext,
Expand All @@ -153,7 +157,8 @@ async def spoiler(self, ctx: ApplicationContext) -> None:
"""Ask for confirmation before reporting a spoiler."""
view = SpoilerConfirmationView(ctx.user)
await ctx.respond(
"Thank you for taking the time to report a spoiler. \n ⚠️ **Warning:** Submitting malicious or fake links will result in consequences.",
"Thank you for taking the time to report a spoiler. \n ⚠️ **Warning:** Submitting malicious or fake links "
"will result in consequences.",
view=view,
ephemeral=True
)
Expand All @@ -180,8 +185,11 @@ async def cheater(
"description": description,
"type": "cheater"
}
headers = {
"X-Automation-Webhook-Token": settings.JIRA_WEBHOOK_SECRET,
}

await webhook.webhook_call(settings.JIRA_WEBHOOK, data)
await webhook.webhook_call(settings.JIRA_WEBHOOK, data, headers)

await ctx.respond("Thank you for your report.", ephemeral=True)

Expand Down
1 change: 1 addition & 0 deletions src/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class Global(BaseSettings):

SLACK_FEEDBACK_WEBHOOK: str = ""
JIRA_WEBHOOK: str = ""
JIRA_WEBHOOK_SECRET: str = ""

ROOT: Path = None

Expand Down
6 changes: 3 additions & 3 deletions src/helpers/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
logger = logging.getLogger(__name__)


async def webhook_call(url: str, data: dict) -> None:
"""Send a POST request to the webhook URL with the given data."""
async def webhook_call(url: str, data: dict, headers: dict = None) -> None:
"""Send a POST request to the webhook URL with the given data and optional headers."""
async with aiohttp.ClientSession() as session:
try:
async with session.post(url, json=data) as response:
async with session.post(url, json=data, headers=headers) as response:
if response.status != 200:
logger.error(f"Failed to send to webhook: {response.status} - {await response.text()}")
except Exception as e:
Expand Down
6 changes: 4 additions & 2 deletions tests/src/cmds/core/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ async def test_spoiler_modal_callback_with_url(self):
"url": "http://example.com/spoiler",
"desc": "Test description",
"type": "spoiler"
}
},
settings.JIRA_WEBHOOK_SECRET
)

@pytest.mark.asyncio
Expand All @@ -168,7 +169,8 @@ async def test_cheater_command(self, bot, ctx):
"cheater": test_username,
"description": test_description,
"type": "cheater"
}
},
settings.JIRA_WEBHOOK_SECRET
)

# Verify the response was sent
Expand Down
Loading