From 8178232911c50e8bebc6e7d88859fc5ef2706ca0 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 14 May 2023 17:21:23 +0100 Subject: [PATCH] Fix Discord webhooks failing due to avatar URL being relative --- app/tasks/webhooktasks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/tasks/webhooktasks.py b/app/tasks/webhooktasks.py index 60df9c45..24500151 100644 --- a/app/tasks/webhooktasks.py +++ b/app/tasks/webhooktasks.py @@ -37,6 +37,8 @@ def post_discord_webhook(username: Optional[str], content: str, is_queue: bool, user = User.query.filter_by(username=username).first() if user: json["avatar_url"] = user.getProfilePicURL().replace("/./", "/") + if json["avatar_url"].startswith("/"): + json["avatar_url"] = app.config["BASE_URL"] + json["avatar_url"] if title: embed = { @@ -51,5 +53,5 @@ def post_discord_webhook(username: Optional[str], content: str, is_queue: bool, res = requests.post(discord_url, json=json, headers={"Accept": "application/json"}) if res.status_code != 200: - print("Failed to submit Discord webhook", res.json(), file=sys.stderr) + raise f"Failed to submit Discord webhook {res.json}" res.raise_for_status()