feat: add search APIs and telegram-like chats sidebar flow
All checks were successful
CI / test (push) Successful in 24s
All checks were successful
CI / test (push) Successful in 24s
- implement chat query filtering and message search endpoints - add db indexes for search fields - activate chats search input in web - replace inline create panel with floating TG-style action menu
This commit is contained in:
@@ -76,6 +76,29 @@ async def get_messages(
|
||||
return await repository.list_chat_messages(db, chat_id, limit=safe_limit, before_id=before_id)
|
||||
|
||||
|
||||
async def search_messages(
|
||||
db: AsyncSession,
|
||||
*,
|
||||
user_id: int,
|
||||
query: str,
|
||||
chat_id: int | None = None,
|
||||
limit: int = 50,
|
||||
) -> list[Message]:
|
||||
normalized = query.strip()
|
||||
if len(normalized) < 2:
|
||||
return []
|
||||
safe_limit = max(1, min(limit, 100))
|
||||
if chat_id is not None:
|
||||
await ensure_chat_membership(db, chat_id=chat_id, user_id=user_id)
|
||||
return await repository.search_messages(
|
||||
db,
|
||||
user_id=user_id,
|
||||
query=normalized,
|
||||
chat_id=chat_id,
|
||||
limit=safe_limit,
|
||||
)
|
||||
|
||||
|
||||
async def update_message(
|
||||
db: AsyncSession,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user