Update get_raw_post_json to using json.dumps
This commit is contained in:
+5
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user