Skip to content

Commit 04d0b1d

Browse files
committed
feat: update GenerateCommentAction to accept Request object and handle JSON payloads
1 parent 985c97a commit 04d0b1d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Actions/GenerateCommentAction.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use CSlant\GitHubProject\Services\GithubService;
66
use CSlant\GitHubProject\Services\WebhookService;
77
use Illuminate\Http\JsonResponse;
8+
use Illuminate\Http\Request;
89
use Throwable;
910

1011
class GenerateCommentAction
@@ -22,16 +23,16 @@ public function __construct(WebhookService $webhookService, GithubService $githu
2223
/**
2324
* Generate a comment message from the webhook payload
2425
*
25-
* @param array<string, mixed>|object $payload
26+
* @param Request $request
2627
* @param bool $validate Whether to validate the payload (default: true)
2728
*
2829
* @return JsonResponse
2930
* @throws Throwable
3031
*/
31-
public function __invoke(array|object $payload, bool $validate = true): JsonResponse
32+
public function __invoke(Request $request, bool $validate = true): JsonResponse
3233
{
3334
try {
34-
$payload = is_object($payload) ? (array) $payload : $payload;
35+
$payload = $request->isJson() ? $request->json()->all() : json_decode($request->getContent(), true);
3536

3637
if ($validate) {
3738
$validationResponse = $this->webhookService->validatePayload($payload);

0 commit comments

Comments
 (0)