aboutsummaryrefslogtreecommitdiffstats
path: root/backend/routes/forms/submit.py
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2021-03-15 02:14:21 +0300
committerGravatar Hassan Abouelela <[email protected]>2021-03-15 02:16:29 +0300
commit4f4dac9c8c863646a8292a9a2db53c0651d96b37 (patch)
treee4274fddbd1dd8544d696533c1ffc7374ee86423 /backend/routes/forms/submit.py
parentAdds Logging To Helpers (diff)
Adds Logging For Routeslogging
Adds logging for most routes, to make it easier to debug the routes, and keep a better record of major changes. Most operations would not get logged, except the beginning of a more sensitive operation, especially ones that require admin permissions. Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'backend/routes/forms/submit.py')
-rw-r--r--backend/routes/forms/submit.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/backend/routes/forms/submit.py b/backend/routes/forms/submit.py
index 2624c98..8810a41 100644
--- a/backend/routes/forms/submit.py
+++ b/backend/routes/forms/submit.py
@@ -5,6 +5,7 @@ Submit a form.
import binascii
import datetime
import hashlib
+import logging
import uuid
from typing import Any, Optional
@@ -24,6 +25,8 @@ from backend.routes.auth.authorize import set_response_token
from backend.routes.forms.unittesting import execute_unittest
from backend.validation import ErrorMessage, api
+logger = logging.getLogger(__name__)
+
HCAPTCHA_VERIFY_URL = "https://hcaptcha.com/siteverify"
HCAPTCHA_HEADERS = {
"Content-Type": "application/x-www-form-urlencoded"
@@ -208,6 +211,10 @@ class SubmitForm(Route):
"""Helper to send a submission message to a discord webhook."""
# Stop if webhook is not available
if form.webhook is None:
+ logger.warning(
+ f"Attempted to submit a form that has "
+ f"webhooks enabled with no webhook url. ID: {form.id}"
+ )
raise ValueError("Got empty webhook.")
try:
@@ -259,6 +266,7 @@ class SubmitForm(Route):
hook["content"] = message.replace("_USER_MENTION_", mention)
# Post hook
+ logger.debug("Attempting to send an embed to the webhook.")
async with httpx.AsyncClient() as client:
r = await client.post(form.webhook.url, json=hook)
r.raise_for_status()