Хранить вложения в приватном S3 и сверять их с PostgreSQL.

This commit is contained in:
2026-11-06 20:13:44 +03:00
parent ec540a1a72
commit a6bb7cbb8b
34 changed files with 3285 additions and 31 deletions
+23
View File
@@ -0,0 +1,23 @@
"""API errors mapped to the contract body. Details stay in server logs."""
class ApiError(Exception):
def __init__(self, status: int, code: str, message: str, headers: dict | None = None):
super().__init__(message)
self.status = status
self.code = code
self.message = message
self.headers = headers or {}
def unauthorized(scheme: str) -> ApiError:
if scheme == "basic":
challenge = 'Basic realm="messenger", charset="UTF-8"'
else:
challenge = 'Bearer realm="messenger"'
return ApiError(
401,
"unauthorized",
"Требуется действительная аутентификация",
{"WWW-Authenticate": challenge},
)