лаба на 4

This commit is contained in:
2026-11-12 00:28:00 +03:00
parent 4602b83074
commit 910252c277
9 changed files with 474 additions and 42 deletions
+14 -7
View File
@@ -724,9 +724,12 @@ async def get_attachment_content_endpoint(
message="Attachment is not ready",
)
if variant == "thumbnail":
if variant == "original":
media_type = attachment.content_type
elif variant in {"thumbnail", "crop", "optimized"}:
selected = next(
(item for item in attachment.variants if item.name == "thumbnail"),
(item for item in attachment.variants if item.name == variant),
None,
)
@@ -737,14 +740,18 @@ async def get_attachment_content_endpoint(
message="Variant not found",
)
s3_key = (
f"variants/{attachment.chat_id}/{attachment_id}/thumbnail.jpg"
extension = {
"thumbnail": "jpg",
"crop": "jpg",
"optimized": "webp",
}[variant]
s3_key = selected.s3_key or (
f"variants/{attachment.chat_id}/{attachment_id}/"
f"{variant}.{extension}"
)
media_type = selected.content_type
elif variant == "original":
media_type = attachment.content_type
else:
raise APIError(
status_code=404,