лаба на 4
This commit is contained in:
+14
-7
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user