mirror of
https://gitlab.crans.org/elkmaennchen/gitscord-webhook
synced 2025-10-12 02:00:06 +02:00
check if the request come from Gitlab
This commit is contained in:
parent
d0fa8493e7
commit
86e2d641b7
1 changed files with 34 additions and 29 deletions
|
@ -41,6 +41,7 @@ if ($plainJSON != '') {
|
||||||
// process Gitlab data
|
// process Gitlab data
|
||||||
$JSON = json_decode($plainJSON, true);
|
$JSON = json_decode($plainJSON, true);
|
||||||
if (is_array($JSON)) { // valid JSON
|
if (is_array($JSON)) { // valid JSON
|
||||||
|
if (isset($_SERVER['HTTP_X_GITLAB_EVENT'])) { // comming from a gitlab instance
|
||||||
switch ($JSON['object_kind']){ // type of event
|
switch ($JSON['object_kind']){ // type of event
|
||||||
case "push": // push event
|
case "push": // push event
|
||||||
$messageJSON = push_layout($messageJSON,$JSON,$lang,$mhl_color);
|
$messageJSON = push_layout($messageJSON,$JSON,$lang,$mhl_color);
|
||||||
|
@ -71,6 +72,10 @@ if ($plainJSON != '') {
|
||||||
default:
|
default:
|
||||||
send_error($url,"Unknown type of event");
|
send_error($url,"Unknown type of event");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
send_error($url,"Unknown git manager. Gitscord only support Gitlab.");
|
||||||
|
}
|
||||||
// sending post request to Discord
|
// sending post request to Discord
|
||||||
send_to_discord($url,$messageJSON);
|
send_to_discord($url,$messageJSON);
|
||||||
exit;
|
exit;
|
||||||
|
|
Loading…
Reference in a new issue