Update get_raw_post_json to using json.dumps

This commit is contained in:
vvzvlad
2025-04-13 03:31:01 +03:00
parent ff97d1190b
commit 96419265a3
+5 -1
View File
@@ -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)