feat-(smoke test passed)
This commit is contained in:
@@ -7,7 +7,7 @@ from src.pydantic_valid.page_response import PageResponse
|
||||
from src.api.dependencies import DbSession, CurrentUser
|
||||
from src.api.repositories.main_repo import Repository
|
||||
from src.utils import generate_id, get_now_iso
|
||||
import datetime
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
@@ -74,7 +74,7 @@ async def list_messages(session: DbSession, current_user: CurrentUser, chat_id:
|
||||
cursor_msg_id = None
|
||||
if cursor:
|
||||
created_at_str, msg_id_str = _decode_msg_cursor(str(chat_id), cursor)
|
||||
cursor_created_at = datetime.fromisoformat(created_at_str.replace("Z", "+00:00"))
|
||||
cursor_created_at = datetime.fromisoformat(created_at_str)
|
||||
cursor_msg_id = UUID(msg_id_str)
|
||||
|
||||
messages, has_more = await repo.messages.get_chat_messages(chat_id=chat_id, limit=limit, cursor_created_at=cursor_created_at, cursor_msg_id=cursor_msg_id)
|
||||
@@ -82,7 +82,7 @@ async def list_messages(session: DbSession, current_user: CurrentUser, chat_id:
|
||||
next_cursor = None
|
||||
if has_more and messages:
|
||||
last = messages[-1]
|
||||
next_cursor = _encode_msg_cursor(chat_id=str(chat_id), created_at=last.created_at.strftime("%Y-%m-%dT%H:%M:%SZ"), msg_id=str(last.id))
|
||||
next_cursor = _encode_msg_cursor(chat_id=str(chat_id), created_at=last.created_at.isoformat(), msg_id=str(last.id))
|
||||
|
||||
return PageResponse(
|
||||
items=[Message(id=str(msg.id), chat_id=str(msg.chat_id), sender_id=str(msg.sender_id), text=msg.text, created_at=msg.created_at.strftime("%Y-%m-%dT%H:%M:%SZ"))
|
||||
|
||||
Reference in New Issue
Block a user