diff options
author | 2022-07-10 01:33:55 +0400 | |
---|---|---|
committer | 2022-07-10 01:33:55 +0400 | |
commit | 8487592e690731a4110acac7210c1cce0fd956f1 (patch) | |
tree | f2d10778c59049965b1396d9353b17d2486e2828 /backend | |
parent | Scope Variables In Unittest Template (diff) |
Check If User Exists Before Sending Webhook
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'backend')
-rw-r--r-- | backend/routes/forms/submit.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/backend/routes/forms/submit.py b/backend/routes/forms/submit.py index db5f4e4..765856e 100644 --- a/backend/routes/forms/submit.py +++ b/backend/routes/forms/submit.py @@ -6,6 +6,7 @@ import asyncio import binascii import datetime import hashlib +import typing import uuid from typing import Any, Optional @@ -295,7 +296,7 @@ class SubmitForm(Route): async def send_submission_webhook( form: Form, response: FormResponse, - request_user: User + request_user: typing.Optional[User] ) -> None: """Helper to send a submission message to a discord webhook.""" # Stop if webhook is not available @@ -305,9 +306,7 @@ class SubmitForm(Route): try: mention = request_user.discord_mention except AttributeError: - mention = "User" - - user = response.user + mention = "A user" # Build Embed embed = { @@ -319,7 +318,8 @@ class SubmitForm(Route): } # Add author to embed - if request_user.is_authenticated: + if request_user and request_user.is_authenticated: + user = response.user embed["author"] = {"name": request_user.display_name} if user and user.avatar: |