File tree Expand file tree Collapse file tree 2 files changed +17
-10
lines changed
Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,8 @@ public function __construct(WebhookService $webhookService)
1818 public function __invoke (): JsonResponse
1919 {
2020 $ request = Request::createFromGlobals ();
21- $ event = $ request ->server ->get ('HTTP_X_GITHUB_EVENT ' );
2221
23- if (!$ this ->webhookService ->eventApproved (( string ) $ event )) {
22+ if (!$ this ->webhookService ->eventRequestApproved ( $ request )) {
2423 return response ()->json (['message ' => __ ('github-project::github-project.error.event.denied ' )], 403 );
2524 }
2625
Original file line number Diff line number Diff line change 33namespace CSlant \GitHubProject \Services ;
44
55use Github \Client ;
6+ use Symfony \Component \HttpFoundation \Request ;
67
78class WebhookService
89{
@@ -18,6 +19,13 @@ public function eventApproved(string $event): bool
1819 return str_contains ($ event , 'project ' );
1920 }
2021
22+ public function eventRequestApproved (Request $ request ): bool
23+ {
24+ $ event = $ request ->server ->get ('HTTP_X_GITHUB_EVENT ' );
25+
26+ return $ this ->eventApproved ((string ) $ event );
27+ }
28+
2129 /**
2230 * @param string $contentNodeId
2331 * @param string $message
@@ -27,17 +35,17 @@ public function eventApproved(string $event): bool
2735 public function commentOnNode (string $ contentNodeId , string $ message ): array
2836 {
2937 $ query = <<<'GRAPHQL'
30- mutation($input: AddCommentInput!) {
31- addComment(input: $input) {
32- commentEdge {
33- node {
34- id
35- body
38+ mutation($input: AddCommentInput!) {
39+ addComment(input: $input) {
40+ commentEdge {
41+ node {
42+ id
43+ body
44+ }
3645 }
3746 }
3847 }
39- }
40- GRAPHQL;
48+ GRAPHQL;
4149
4250 $ variables = [
4351 'input ' => [
You can’t perform that action at this time.
0 commit comments