{"action":"created","issue":{"url":"https://api.github.com/repos/corpsee/php-censor/issues/13","repository_url":"https://api.github.com/repos/corpsee/php-censor","labels_url":"https://api.github.com/repos/corpsee/php-censor/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/corpsee/php-censor/issues/13/comments","events_url":"https://api.github.com/repos/corpsee/php-censor/issues/13/events","html_url":"https://github.com/corpsee/php-censor/issues/13","id":205510265,"number":13,"title":"[Feature] add gogs support","user":{"login":"vinpel","id":1699839,"avatar_url":"https://avatars.githubusercontent.com/u/1699839?v=3","gravatar_id":"","url":"https://api.github.com/users/vinpel","html_url":"https://github.com/vinpel","followers_url":"https://api.github.com/users/vinpel/followers","following_url":"https://api.github.com/users/vinpel/following{/other_user}","gists_url":"https://api.github.com/users/vinpel/gists{/gist_id}","starred_url":"https://api.github.com/users/vinpel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vinpel/subscriptions","organizations_url":"https://api.github.com/users/vinpel/orgs","repos_url":"https://api.github.com/users/vinpel/repos","events_url":"https://api.github.com/users/vinpel/events{/privacy}","received_events_url":"https://api.github.com/users/vinpel/received_events","type":"User","site_admin":false},"labels":[{"id":532406367,"url":"https://api.github.com/repos/corpsee/php-censor/labels/feature","name":"feature","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":{"login":"vinpel","id":1699839,"avatar_url":"https://avatars.githubusercontent.com/u/1699839?v=3","gravatar_id":"","url":"https://api.github.com/users/vinpel","html_url":"https://github.com/vinpel","followers_url":"https://api.github.com/users/vinpel/followers","following_url":"https://api.github.com/users/vinpel/following{/other_user}","gists_url":"https://api.github.com/users/vinpel/gists{/gist_id}","starred_url":"https://api.github.com/users/vinpel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vinpel/subscriptions","organizations_url":"https://api.github.com/users/vinpel/orgs","repos_url":"https://api.github.com/users/vinpel/repos","events_url":"https://api.github.com/users/vinpel/events{/privacy}","received_events_url":"https://api.github.com/users/vinpel/received_events","type":"User","site_admin":false},"assignees":[{"login":"vinpel","id":1699839,"avatar_url":"https://avatars.githubusercontent.com/u/1699839?v=3","gravatar_id":"","url":"https://api.github.com/users/vinpel","html_url":"https://github.com/vinpel","followers_url":"https://api.github.com/users/vinpel/followers","following_url":"https://api.github.com/users/vinpel/following{/other_user}","gists_url":"https://api.github.com/users/vinpel/gists{/gist_id}","starred_url":"https://api.github.com/users/vinpel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vinpel/subscriptions","organizations_url":"https://api.github.com/users/vinpel/orgs","repos_url":"https://api.github.com/users/vinpel/repos","events_url":"https://api.github.com/users/vinpel/events{/privacy}","received_events_url":"https://api.github.com/users/vinpel/received_events","type":"User","site_admin":false}],"milestone":null,"comments":5,"created_at":"2017-02-06T07:58:56Z","updated_at":"2017-02-07T16:09:18Z","closed_at":null,"body":"Gogs : https://gogs.io/\r\n\r\nIn controller/WebhookController.php add this 2 methods to the class :\r\n(not by me from a commit not accepted in phpci repo)\r\n\r\nmaybe create a gogs project type, actualy i need to set type : \"remote url\" and set authentification in the url)\r\n\r\n```php\r\n<?php\r\n/**\r\n      * Called by Gogs Webhooks:\r\n      */\r\n     public function gogs($projectId)\r\n     {\r\n         $project = $this->fetchProject($projectId, 'remote');\r\n \r\n         switch ($_SERVER['CONTENT_TYPE']) {\r\n             case 'application/json':\r\n                 $payload = json_decode(file_get_contents('php://input'), true);\r\n                 break;\r\n             case 'application/x-www-form-urlencoded':\r\n                 $payload = json_decode($this->getParam('payload'), true);\r\n                 break;\r\n             default:\r\n                 return array('status' => 'failed', 'error' => 'Content type not supported.', 'responseCode' => 401);\r\n         }\r\n \r\n         // Handle Push web hooks:\r\n         if (array_key_exists('commits', $payload)) {\r\n             return $this->gogsCommitRequest($project, $payload);\r\n         }\r\n \r\n         return array('status' => 'ignored', 'message' => 'Unusable payload.');\r\n     }\r\n \r\n     /**\r\n      * Handle the payload when Gogs sends a commit webhook.\r\n      *\r\n      * @param Project $project\r\n      * @param array $payload\r\n      * @param b8\\Http\\Response\\JsonResponse $response\r\n      *\r\n      * @return b8\\Http\\Response\\JsonResponse\r\n      */\r\n     protected function gogsCommitRequest(Project $project, array $payload)\r\n     {\r\n         if (isset($payload['commits']) && is_array($payload['commits'])) {\r\n             // If we have a list of commits, then add them all as builds to be tested:\r\n             $results = array();\r\n             $status = 'failed';\r\n             foreach ($payload['commits'] as $commit) {\r\n                 try {\r\n                     $branch = str_replace('refs/heads/', '', $payload['ref']);\r\n                     $committer = $commit['author']['email'];\r\n                     $results[$commit['id']] = $this->createBuild(\r\n                         $project,\r\n                         $commit['id'],\r\n                         $branch,\r\n                         $committer,\r\n                         $commit['message']\r\n                     );\r\n                     $status = 'ok';\r\n                 } catch (Exception $ex) {\r\n                     $results[$commit['id']] = array('status' => 'failed', 'error' => $ex->getMessage());\r\n                 }\r\n             }\r\n             return array('status' => $status, 'commits' => $results);\r\n         }\r\n \r\n         return array('status' => 'ignored', 'message' => 'Unusable payload.');\r\n     }`"},"comment":{"url":"https://api.github.com/repos/corpsee/php-censor/issues/comments/278047191","html_url":"https://github.com/corpsee/php-censor/issues/13#issuecomment-278047191","issue_url":"https://api.github.com/repos/corpsee/php-censor/issues/13","id":278047191,"user":{"login":"corpsee","id":1416706,"avatar_url":"https://avatars.githubusercontent.com/u/1416706?v=3","gravatar_id":"","url":"https://api.github.com/users/corpsee","html_url":"https://github.com/corpsee","followers_url":"https://api.github.com/users/corpsee/followers","following_url":"https://api.github.com/users/corpsee/following{/other_user}","gists_url":"https://api.github.com/users/corpsee/gists{/gist_id}","starred_url":"https://api.github.com/users/corpsee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corpsee/subscriptions","organizations_url":"https://api.github.com/users/corpsee/orgs","repos_url":"https://api.github.com/users/corpsee/repos","events_url":"https://api.github.com/users/corpsee/events{/privacy}","received_events_url":"https://api.github.com/users/corpsee/received_events","type":"User","site_admin":false},"created_at":"2017-02-07T16:09:18Z","updated_at":"2017-02-07T16:09:18Z","body":"Thanks you for testing"}}
{"actor":{"display_login":"corpsee"}}