feat(web): improve message UX, voice gestures, and attachments
Some checks failed
CI / test (push) Failing after 21s
Some checks failed
CI / test (push) Failing after 21s
This commit is contained in:
@@ -10,7 +10,8 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.config.settings import settings
|
||||
from app.media import repository
|
||||
from app.media.schemas import AttachmentCreateRequest, AttachmentRead, UploadUrlRequest, UploadUrlResponse
|
||||
from app.media.schemas import AttachmentCreateRequest, AttachmentRead, ChatAttachmentRead, UploadUrlRequest, UploadUrlResponse
|
||||
from app.chats.service import ensure_chat_membership
|
||||
from app.messages.repository import get_message_by_id
|
||||
|
||||
ALLOWED_MIME_TYPES = {
|
||||
@@ -134,3 +135,32 @@ async def store_attachment_metadata(
|
||||
await db.commit()
|
||||
await db.refresh(attachment)
|
||||
return AttachmentRead.model_validate(attachment)
|
||||
|
||||
|
||||
async def list_attachments_for_chat(
|
||||
db: AsyncSession,
|
||||
*,
|
||||
user_id: int,
|
||||
chat_id: int,
|
||||
limit: int = 100,
|
||||
before_id: int | None = None,
|
||||
) -> list[ChatAttachmentRead]:
|
||||
await ensure_chat_membership(db, chat_id=chat_id, user_id=user_id)
|
||||
rows = await repository.list_chat_attachments(
|
||||
db,
|
||||
chat_id=chat_id,
|
||||
limit=max(1, min(limit, 200)),
|
||||
before_id=before_id,
|
||||
)
|
||||
return [
|
||||
ChatAttachmentRead(
|
||||
id=attachment.id,
|
||||
message_id=attachment.message_id,
|
||||
sender_id=message.sender_id,
|
||||
message_created_at=message.created_at,
|
||||
file_url=attachment.file_url,
|
||||
file_type=attachment.file_type,
|
||||
file_size=attachment.file_size,
|
||||
)
|
||||
for attachment, message in rows
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user