* Adjust gitlab commit sync api.

This commit is contained in:
caoyanyi
2024-01-02 19:50:53 +08:00
parent 41eb9007ef
commit dac80bd354
2 changed files with 11 additions and 9 deletions
+10 -8
View File
@@ -20,19 +20,21 @@ class gitlabWebhookEntry extends baseEntry
*/
public function post()
{
$repoID = $this->param('repoID');
if(empty($repoID)) return;
$this->loadModel('repo');
$repo = $this->repo->getByID($repoID);
if(empty($repo)) return;
$headers = getallheaders(); /* Fetch all HTTP request headers. */
$event = isset($headers['X-Gitlab-Event']) ? $headers['X-Gitlab-Event'] : '';
$token = isset($headers['X-Gitlab-Token']) ? $headers['X-Gitlab-Token'] : '';
if(empty($event) || empty($token)) return;
$repoID = $this->param('repoID');
if(empty($repoID)) return;
$this->app->user = new stdclass();
$this->app->user->account = '';
$this->app->user->admin = false;
$repo = $this->loadModel('repo')->getByID($repoID);
if(empty($repo)) return;
$this->repo->handleWebhook($event, $this->requestBody, $repo);
}
}
+1 -1
View File
@@ -79,7 +79,7 @@ class gitlabModel extends model
if(!$gitlab) return '';
$sudoParam = '';
if($sudo == true and !$this->app->user->admin)
if($sudo == true && !$this->app->user->admin)
{
$openID = $this->loadModel('pipeline')->getOpenIdByAccount($gitlabID, 'gitlab', $this->app->user->account);
if($openID) $sudoParam = "&sudo={$openID}";