From f20dfa2017de382653056768dedf6adf8f5dc670 Mon Sep 17 00:00:00 2001 From: Aron BenDaniel <144371000+AaronBenDaniel@users.noreply.github.com> Date: Thu, 30 Oct 2025 13:43:12 -0400 Subject: [PATCH] feat(api): Made PDFs-enabled check earlier --- src/api/src/main.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/api/src/main.py b/src/api/src/main.py index 93eae99..854676a 100644 --- a/src/api/src/main.py +++ b/src/api/src/main.py @@ -161,6 +161,13 @@ async def handle_download( else: cookies = None + if format == DownloadFormat.pdf and not PDFS_ENABLED: + logger.error("PDF Downloads not enabled.") + return HTMLResponse( + status_code=403, + content='PDF Downloads have been disabled by the server administrator. Support is available on the Discord', + ) + match mode: case DownloadMode.story: story_id = download_id @@ -195,12 +202,6 @@ async def handle_download( book = EPUBGenerator(metadata, part_trees, cover_data, images) media_type = "application/epub+zip" case DownloadFormat.pdf: - if not PDFS_ENABLED: - logger.error("PDF Downloads not enabled.") - return HTMLResponse( - status_code=403, - content='PDF Downloads have been disabled by the server administrator. Support is available on the Discord', - ) author_image = await fetch_image( metadata["user"]["avatar"].replace("-256-", "-512-") )