Skip to content
Snippets Groups Projects
Select Git revision
  • 5d0148033cba3a36372f993db57a9959879c3597
  • main default protected
  • step-3263
  • feature/plugins-cli
  • feature/vite
  • step-2484-peerreview
  • biest/issue-5051
  • tests/simplify-jsonapi-tests
  • fix/typo-in-1a70031
  • feature/broadcasting
  • database-seeders-and-factories
  • feature/peer-review-2
  • feature-feedback-jsonapi
  • feature/peerreview
  • feature/balloon-plus
  • feature/stock-images-unsplash
  • tic-2588
  • 5.0
  • 5.2
  • biest/unlock-blocks
  • biest-1514
21 results

functions.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    hooks.php 1.65 KiB
    <?php
    use TracToGitlab\EventController;
    use TracToGitlab\EventHandler;
    use TracToGitlab\EventHandlers;
    
    final class HooksController extends EventController
    {
        public function system_action()
        {
            if (!$this->verifySecret(Config::get()->getValue('TRAC2GITLAB_GITLAB_SYSTEMHOOK_SECRET'))) {
                $this->halt('Thou shalt not pass.', 403);
            }
    
            if (!$this->verifyEvent()) {
                $this->halt('This is not a valid gitlab event');
            }
    
            $this->processHooks($this->getKnownSystemhooks());
        }
    
        /**
         * @return iterator|EventHandler[]
         */
        private function getKnownSystemhooks(): iterator
        {
            yield app(EventHandlers\UserCreated::class);
        }
    
        public function web_action()
        {
    //        if (!$this->verifySecret(Config::get()->getValue('TRAC2GITLAB_GITLAB_WEBHOOK_SECRET'))) {
    //            $this->halt('Thou shalt not pass.', 403);
    //        }
    //
    
            dd(app(EventHandlers\BranchDeleted::class));
    
            $payload = $this->payload();
    
            if (
                !$this->verifyEvent()
                || !isset($payload['project']['id'])
                || $payload['project']['id'] != $this->gitlab_project_id
            ) {
                $this->halt('This is not a valid gitlab event');
            }
    
            $this->processHooks($this->getKnownWebhooks());
        }
    
        /**
         * @return iterator|EventHandler[]
         */
        private function getKnownWebhooks(): iterator
        {
            yield app(EventHandlers\AllAutomaticJobsHaveSucceeded::class);
            yield app(EventHandlers\BranchDeleted::class);
            yield app(EventHandlers\BuildImageJobSucceeded::class);
            yield app(EventHandlers\IssueCreated::class);
        }
    }