feat(web): improve message UX, voice gestures, and attachments
Some checks failed
CI / test (push) Failing after 21s

This commit is contained in:
2026-03-08 10:20:52 +03:00
parent 52c41b6958
commit 6a96a99775
9 changed files with 857 additions and 212 deletions

View File

@@ -1,6 +1,8 @@
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.media.models import Attachment
from app.messages.models import Message
async def create_attachment(
@@ -24,3 +26,23 @@ async def create_attachment(
async def get_attachment_by_id(db: AsyncSession, attachment_id: int) -> Attachment | None:
return await db.get(Attachment, attachment_id)
async def list_chat_attachments(
db: AsyncSession,
*,
chat_id: int,
limit: int = 100,
before_id: int | None = None,
) -> list[tuple[Attachment, Message]]:
stmt = (
select(Attachment, Message)
.join(Message, Message.id == Attachment.message_id)
.where(Message.chat_id == chat_id)
.order_by(Attachment.id.desc())
.limit(limit)
)
if before_id is not None:
stmt = stmt.where(Attachment.id < before_id)
result = await db.execute(stmt)
return [(row[0], row[1]) for row in result.all()]