feat: complete lab4 attachment endpoints, s3 storage and updated_at field

This commit is contained in:
2026-11-11 21:11:47 +03:00
parent b815cef838
commit 95466a864a
7 changed files with 135 additions and 223 deletions
+5 -18
View File
@@ -1,8 +1,6 @@
from uuid import UUID
from pydantic import BaseModel, ConfigDict, Field, field_validator
class CreateUser(BaseModel):
model_config = ConfigDict(extra="forbid")
username: str = Field(pattern=r"^[a-z0-9_]{3,32}$")
@@ -16,7 +14,6 @@ class CreateUser(BaseModel):
raise ValueError("must not be blank")
return v
class CreateChat(BaseModel):
model_config = ConfigDict(extra="forbid")
title: str = Field(min_length=1, max_length=100)
@@ -36,18 +33,11 @@ class CreateChat(BaseModel):
raise ValueError("duplicate member_ids")
return v
class CreateMessage(BaseModel):
model_config = ConfigDict(extra="forbid")
text: str = Field(min_length=1, max_length=4000)
@field_validator("text")
@classmethod
def _text_not_blank(cls, v: str) -> str:
if not v.strip():
raise ValueError("text must not be blank")
return v
# min_length=0 разрешает пустой текст, если прикреплен файл
text: str = Field(min_length=0, max_length=4000)
attachment_ids: list[UUID] | None = None
class SessionResponse(BaseModel):
token: str
@@ -66,9 +56,6 @@ class AttachmentResponse(BaseModel):
sha256: str
status: str
error_code: str | None = None
variants: list = []
created_at: str
class CreateMessage(BaseModel):
model_config = ConfigDict(extra="forbid")
text: str = Field(min_length=1, max_length=4000)
attachment_ids: list[UUID] | None = None
updated_at: str