add level 4

This commit is contained in:
Матвей
2026-10-26 10:29:54 +03:00
parent df15ab0967
commit ff33b8a7c2
9 changed files with 265 additions and 40 deletions
+3 -7
View File
@@ -1,5 +1,4 @@
import asyncio
from datetime import datetime, timezone
from hashlib import sha256
import os
from tempfile import TemporaryFile
@@ -16,7 +15,6 @@ from .errors import ApiError
from .models import Attachment
from .routes import get_current_user, get_store
from .storage.postgres import PostgresStore
from .broker import publish
router = APIRouter()
Image.MAX_IMAGE_PIXELS = 40000000
@@ -93,11 +91,9 @@ async def upload(chat_id: UUID, request: Request, filename: str = Query(...),
attachment_id, chat_id, user["id"], filename, content_type,
size, digest.hexdigest(), key, job_id, connection=connection,
)
await publish({
"schema_version": 1, "job_id": str(job_id), "type": "attachment.process.v1",
"attachment_id": str(attachment_id), "pipeline_version": 1, "attempt": 1,
"created_at": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
})
# Fault-injection for level-4 proof: durable outbox must recover this commit.
if os.environ.get("OUTBOX_FAULT_AFTER_COMMIT") == "1":
os._exit(70)
attachment["variants"] = []
return attachment
except ClientDisconnect: