From ed7b43ecac2fd527acec3b698ce3c7242e72f859 Mon Sep 17 00:00:00 2001 From: Evgeny Bushkov Date: Fri, 23 Oct 2026 18:38:19 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D0=BC=D0=B8=D0=BA=D1=80=D0=BE=D1=81=D0=B5?= =?UTF-8?q?=D0=BA=D1=83=D0=BD=D0=B4=D1=8B=20=D0=B2=20created=5Fat=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20keyset-=D0=BF=D0=B0=D0=B3=D0=B8=D0=BD=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: aider (deepseek/deepseek-chat) --- app/handlers.py | 11 ++--------- app/store.py | 7 ++----- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/app/handlers.py b/app/handlers.py index 2f4ef276..ad1f1d84 100644 --- a/app/handlers.py +++ b/app/handlers.py @@ -161,7 +161,6 @@ def create_chat( if store.get_user(mid) is None: raise ApiError(400, "invalid_request", "Неизвестный участник чата") chat = store.create_chat(title, member_ids) - chat.pop("_cursor_created_at", None) return JSONResponse(chat, status_code=201) @@ -180,9 +179,7 @@ def list_chats( next_cursor = None if has_more and items: last = items[-1] - next_cursor = encode_cursor(last["_cursor_created_at"], last["id"], scope) - for item in items: - item.pop("_cursor_created_at", None) + next_cursor = encode_cursor(last["created_at"], last["id"], scope) return {"items": items, "next_cursor": next_cursor} @@ -200,7 +197,6 @@ def get_chat( chat = store.get_chat(chat_id) if chat is None: raise ApiError(404, "not_found", "Чат не найден") - chat.pop("_cursor_created_at", None) return chat @@ -218,7 +214,6 @@ def create_message( raise ApiError(404, "not_found", "Чат не найден") text = validate_create_message(body) message = store.add_message(chat_id, caller, text) - message.pop("_cursor_created_at", None) return JSONResponse(message, status_code=201) @@ -242,7 +237,5 @@ def list_messages( next_cursor = None if has_more and items: last = items[-1] - next_cursor = encode_cursor(last["_cursor_created_at"], last["id"], scope) - for item in items: - item.pop("_cursor_created_at", None) + next_cursor = encode_cursor(last["created_at"], last["id"], scope) return {"items": items, "next_cursor": next_cursor} diff --git a/app/store.py b/app/store.py index 3a4eed10..cda7ea37 100644 --- a/app/store.py +++ b/app/store.py @@ -17,7 +17,8 @@ def new_id() -> str: def _iso(dt: datetime) -> str: - return dt.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") + """RFC 3339 UTC с суффиксом Z, микросекунды сохраняются для keyset-пагинации.""" + return dt.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ") def _user_row(row: tuple) -> dict[str, Any]: @@ -37,8 +38,6 @@ def _chat_row(row: tuple, member_ids: list[str]) -> dict[str, Any]: "title": title, "member_ids": member_ids, "created_at": _iso(created_at), - # Полное значение для keyset-cursor; handler вырезает перед отдачей. - "_cursor_created_at": created_at.isoformat(), } @@ -50,8 +49,6 @@ def _message_row(row: tuple) -> dict[str, Any]: "sender_id": str(sender_id), "text": text, "created_at": _iso(created_at), - # Полное значение для keyset-cursor; handler вырезает перед отдачей. - "_cursor_created_at": created_at.isoformat(), }