Skip to content

Commit 517bd77

Browse files
committed
feat: improve JSON payload handling in GenerateCommentAction
1 parent f17fb8c commit 517bd77

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Actions/GenerateCommentAction.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ public function __invoke(Request $request, bool $validate = true): JsonResponse
3434
$startTime = microtime(true);
3535

3636
try {
37-
$payload = $request->isJson() ? $request->json()->all() : json_decode($request->getContent(), true);
37+
if ($request->isJson()) {
38+
$jsonContent = $request->json();
39+
$payload = is_object($jsonContent) && method_exists($jsonContent, 'all')
40+
? $jsonContent->all()
41+
: (array) $jsonContent;
42+
} else {
43+
$payload = json_decode($request->getContent(), true);
44+
}
3845

3946
if (!empty($payload['payload'])) {
4047
$payload = $payload['payload'];

0 commit comments

Comments
 (0)