fix(pheby): restore paged history across session resets
This commit is contained in:
+12
-2
@@ -426,8 +426,17 @@ class PhebyServer:
|
||||
limit = max(1, min(int(limit), proto.MAX_HISTORY_MESSAGES))
|
||||
except (TypeError, ValueError):
|
||||
limit = proto.MAX_HISTORY_MESSAGES
|
||||
history, found = await self.bridge.conversation_history(
|
||||
conversation_id, limit)
|
||||
cursor = message.get("before_message_id")
|
||||
before_id = None
|
||||
if cursor is not None:
|
||||
if (not isinstance(cursor, str) or not cursor.startswith("m")
|
||||
or not cursor[1:].isdigit() or len(cursor) > 20):
|
||||
await client.send_json(proto.error_event(
|
||||
proto.ERR_BAD_REQUEST, "Invalid before_message_id", request_id))
|
||||
return
|
||||
before_id = int(cursor[1:])
|
||||
history, found, has_more = await self.bridge.conversation_history(
|
||||
conversation_id, limit, before_id=before_id)
|
||||
if not found:
|
||||
await client.send_json(proto.error_event(
|
||||
proto.ERR_CONVERSATION_NOT_FOUND,
|
||||
@@ -438,6 +447,7 @@ class PhebyServer:
|
||||
"type": proto.S_CONVERSATION_HISTORY,
|
||||
"conversation_id": conversation_id,
|
||||
"messages": history,
|
||||
"has_more": has_more,
|
||||
"attachments": self.store.list_for_conversation(conversation_id),
|
||||
**runtime,
|
||||
**({"request_id": request_id} if request_id else {}),
|
||||
|
||||
Reference in New Issue
Block a user