From 96419265a30205cd5159fcd382c9cca104757305 Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Sun, 13 Apr 2025 03:31:01 +0300 Subject: [PATCH] Update get_raw_post_json to using json.dumps --- api_server.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api_server.py b/api_server.py index 2c93cf8..87f5bc8 100644 --- a/api_server.py +++ b/api_server.py @@ -650,7 +650,11 @@ async def get_raw_post_json(channel: str, post_id: int, token: str | None = None if not message: raise HTTPException(status_code=404, detail="Post not found") - return JSONResponse(content=message, media_type="application/json") + # Return message as JSON using json.dumps with default=str to handle non-serializable objects + return Response( + content=json.dumps(message, indent=2, ensure_ascii=False, default=str), + media_type="application/json" + ) except Exception as e: error_message = f"Failed to get raw JSON post for channel {channel}, post_id {post_id}: {str(e)}" logger.error(error_message)