diff options
-rw-r--r-- | backend/models/form.py | 2 | ||||
-rw-r--r-- | backend/routes/forms/submit.py | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/backend/models/form.py b/backend/models/form.py index 6c435e7..9a3a8a2 100644 --- a/backend/models/form.py +++ b/backend/models/form.py @@ -66,7 +66,7 @@ class Form(BaseModel): questions: list[Question] name: str description: str - meta: _FormMeta + meta: _FormMeta = _FormMeta() class Config: allow_population_by_field_name = True diff --git a/backend/routes/forms/submit.py b/backend/routes/forms/submit.py index c476468..538a5b9 100644 --- a/backend/routes/forms/submit.py +++ b/backend/routes/forms/submit.py @@ -152,7 +152,7 @@ class SubmitForm(Route): }) @staticmethod - def send_submission_webhook(form: Form, response: FormResponse) -> None: + async def send_submission_webhook(form: Form, response: FormResponse) -> None: """Helper to send a submission message to a discord webhook.""" # Stop if webhook is not available if form.meta.webhook is None: @@ -189,7 +189,9 @@ class SubmitForm(Route): # Set hook message message = form.meta.webhook.message if message: - hook["content"] = message.replace("_USER_MENTION_", f"<@{user.id}>") + hook["content"] = message.replace("_USER_MENTION_", user_mention) # Post hook - httpx.post(form.meta.webhook.url, json=hook).raise_for_status() + async with httpx.AsyncClient() as client: + r = await client.post(form.meta.webhook.url, json=hook) + r.raise_for_status() |