first commit

This commit is contained in:
2026-03-07 21:31:38 +03:00
commit a879ba7b50
68 changed files with 2487 additions and 0 deletions

26
app/media/repository.py Normal file
View File

@@ -0,0 +1,26 @@
from sqlalchemy.ext.asyncio import AsyncSession
from app.media.models import Attachment
async def create_attachment(
db: AsyncSession,
*,
message_id: int,
file_url: str,
file_type: str,
file_size: int,
) -> Attachment:
attachment = Attachment(
message_id=message_id,
file_url=file_url,
file_type=file_type,
file_size=file_size,
)
db.add(attachment)
await db.flush()
return attachment
async def get_attachment_by_id(db: AsyncSession, attachment_id: int) -> Attachment | None:
return await db.get(Attachment, attachment_id)