human hand off bug
This commit is contained in:
parent
223f846782
commit
6e7a0b9539
22 changed files with 1040 additions and 336 deletions
|
|
@ -21,6 +21,8 @@ from app.schemas import (
|
|||
MessageReadState,
|
||||
MessageStarState,
|
||||
MessageSummary,
|
||||
parse_api_datetime,
|
||||
utc_iso,
|
||||
utc_now,
|
||||
)
|
||||
from app.services.domain_provisioning import get_domain_by_name
|
||||
|
|
@ -72,7 +74,7 @@ def address(value: str, name: str | None = None) -> dict[str, str]:
|
|||
|
||||
def encode_cursor(entry: dict) -> str:
|
||||
value = json.dumps(
|
||||
{"created_at": entry["created_at"].isoformat(), "id": str(entry["_id"])},
|
||||
{"created_at": utc_iso(entry["created_at"]), "id": str(entry["_id"])},
|
||||
separators=(",", ":"),
|
||||
)
|
||||
return base64.urlsafe_b64encode(value.encode()).decode().rstrip("=")
|
||||
|
|
@ -82,7 +84,7 @@ def decode_cursor(value: str) -> tuple[datetime, ObjectId]:
|
|||
try:
|
||||
padded = value + "=" * (-len(value) % 4)
|
||||
payload = json.loads(base64.urlsafe_b64decode(padded).decode())
|
||||
return datetime.fromisoformat(payload["created_at"]), ObjectId(payload["id"])
|
||||
return parse_api_datetime(payload["created_at"]), ObjectId(payload["id"])
|
||||
except (ValueError, TypeError, KeyError, json.JSONDecodeError) as error:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue