feat: improve chat realtime and media composer UX
All checks were successful
CI / test (push) Successful in 27s
All checks were successful
CI / test (push) Successful in 27s
- add media preview and upload confirmation for image/video - add upload progress tracking for presigned uploads - keep voice recording/upload flow with better UI states - include related realtime/chat updates currently in working tree
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from sqlalchemy import Select, select
|
||||
from sqlalchemy.orm import aliased
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.chats.models import Chat, ChatMember, ChatMemberRole, ChatType
|
||||
@@ -60,3 +61,21 @@ async def list_user_chat_ids(db: AsyncSession, *, user_id: int) -> list[int]:
|
||||
select(ChatMember.chat_id).where(ChatMember.user_id == user_id).order_by(ChatMember.chat_id.asc())
|
||||
)
|
||||
return list(result.scalars().all())
|
||||
|
||||
|
||||
async def find_private_chat_between_users(db: AsyncSession, *, user_a_id: int, user_b_id: int) -> Chat | None:
|
||||
cm_a = aliased(ChatMember)
|
||||
cm_b = aliased(ChatMember)
|
||||
stmt = (
|
||||
select(Chat)
|
||||
.join(cm_a, cm_a.chat_id == Chat.id)
|
||||
.join(cm_b, cm_b.chat_id == Chat.id)
|
||||
.where(
|
||||
Chat.type == ChatType.PRIVATE,
|
||||
cm_a.user_id == user_a_id,
|
||||
cm_b.user_id == user_b_id,
|
||||
)
|
||||
.limit(1)
|
||||
)
|
||||
result = await db.execute(stmt)
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
Reference in New Issue
Block a user