feat(api): Made PDFs-enabled check earlier

This commit is contained in:
Aron BenDaniel
2025-10-30 13:43:12 -04:00
parent 265799907d
commit f20dfa2017
+7 -6
View File
@@ -161,6 +161,13 @@ async def handle_download(
else: else:
cookies = None 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 <a href="https://discord.gg/P9RHC4KCwd" target="_blank">Discord</a>',
)
match mode: match mode:
case DownloadMode.story: case DownloadMode.story:
story_id = download_id story_id = download_id
@@ -195,12 +202,6 @@ async def handle_download(
book = EPUBGenerator(metadata, part_trees, cover_data, images) book = EPUBGenerator(metadata, part_trees, cover_data, images)
media_type = "application/epub+zip" media_type = "application/epub+zip"
case DownloadFormat.pdf: 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 <a href="https://discord.gg/P9RHC4KCwd" target="_blank">Discord</a>',
)
author_image = await fetch_image( author_image = await fetch_image(
metadata["user"]["avatar"].replace("-256-", "-512-") metadata["user"]["avatar"].replace("-256-", "-512-")
) )