File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1111 'access_token ' => env ('GITHUB_ACCESS_TOKEN ' , '' ),
1212 'graphql_url ' => env ('GITHUB_GRAPHQL_URL ' , 'https://api.github.com/graphql ' ),
1313 ],
14+
15+ 'enable_status_comment ' => env ('GITHUB_PROJECT_ENABLE_STATUS_COMMENT ' , false ),
1416];
Original file line number Diff line number Diff line change 1010 'denied ' => 'The event was denied. ' ,
1111 'action_not_found ' => 'Not an action event. ' ,
1212 'missing_fields ' => 'Missing required fields. ' ,
13+ 'status_comment_disabled ' => 'Status comment is disabled. ' ,
1314 ],
1415 ],
1516
Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ public function validatePayload(array $payload): ?JsonResponse
3737 if (!isset ($ payload ['action ' ])) {
3838 return response ()->json (
3939 ['message ' => __ ('github-project::github-project.error.event.action_not_found ' )],
40+ 404
41+ );
42+ }
43+
44+ if (!$ this ->isStatusCommentEnabled ($ payload ['changes ' ]['field_value ' ]['field_name ' ])) {
45+ return response ()->json (
46+ ['message ' => __ ('github-project::github-project.error.event.status_comment_disabled ' )],
4047 400
4148 );
4249 }
@@ -54,6 +61,22 @@ public function validatePayload(array $payload): ?JsonResponse
5461 return null ;
5562 }
5663
64+ /**
65+ * Check if the field name is "Status" and if status comments are enabled.
66+ *
67+ * @param string $fieldName
68+ *
69+ * @return bool
70+ */
71+ public function isStatusCommentEnabled (string $ fieldName ): bool
72+ {
73+ if ($ fieldName === 'Status ' && !config ('github-project.enable_status_comment ' )) {
74+ return false ;
75+ }
76+
77+ return true ;
78+ }
79+
5780 /**
5881 * @param string $contentNodeId
5982 * @param string $message
You can’t perform that action at this time.
0 commit comments