From f7779ace6049851fcfc3935780f76c11a752efe4 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Tue, 7 Nov 2023 02:12:55 +0100 Subject: [PATCH] Fix crash in case of vanity code and not found --- divent/bot.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/divent/bot.py b/divent/bot.py index 34571ba..90fc49b 100644 --- a/divent/bot.py +++ b/divent/bot.py @@ -221,7 +221,10 @@ async def subscribe(entity_id: str): entity_id=guild.vanity_url_code or guild.id, ) - user = await client.get_or_fetch_user(int(entity_id)) + try: + user = await client.get_or_fetch_user(int(entity_id)) + except ValueError: + return redirect(url_for(".login")) if user and str(user.id) == entity_id: return await render_template( @@ -281,7 +284,10 @@ async def ical(entity_id: str): return calendar.serialize() - user = await client.get_or_fetch_user(int(entity_id)) + try: + user = await client.get_or_fetch_user(int(entity_id)) + except ValueError: + return redirect(url_for(".login")) if user: calendar = Calendar()