summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-12-28 22:22:15 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-12-28 22:22:15 -0500
commit5266b821446b14b79a3c5a5c77c57791b985f0a9 (patch)
treedf0719492193e0ba842430edbbab8cd02775fbc5 /app/Controller
parentd6530bd55fdd863f0cf153bc2854fb4e34076316 (diff)
Add Gitlab webhook
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/Project.php17
-rw-r--r--app/Controller/Webhook.php22
2 files changed, 37 insertions, 2 deletions
diff --git a/app/Controller/Project.php b/app/Controller/Project.php
index 9037a91a..a7e8a39b 100644
--- a/app/Controller/Project.php
+++ b/app/Controller/Project.php
@@ -52,7 +52,6 @@ class Project extends Base
$this->response->html($this->projectLayout('project/show', array(
'project' => $project,
'stats' => $this->project->getStats($project['id']),
- 'webhook_token' => $this->config->get('webhook_token'),
'title' => $project['name'],
)));
}
@@ -153,6 +152,22 @@ class Project extends Base
}
/**
+ * Integrations page
+ *
+ * @access public
+ */
+ public function integration()
+ {
+ $project = $this->getProjectManagement();
+
+ $this->response->html($this->projectLayout('project/integrations', array(
+ 'project' => $project,
+ 'title' => t('Integrations'),
+ 'webhook_token' => $this->config->get('webhook_token'),
+ )));
+ }
+
+ /**
* Display a form to edit a project
*
* @access public
diff --git a/app/Controller/Webhook.php b/app/Controller/Webhook.php
index dcd66a1a..1ae3b0a4 100644
--- a/app/Controller/Webhook.php
+++ b/app/Controller/Webhook.php
@@ -57,7 +57,27 @@ class Webhook extends Base
$result = $this->githubWebhook->parsePayload(
$this->request->getHeader('X-Github-Event'),
- $this->request->getJson()
+ $this->request->getJson() ?: array()
+ );
+
+ echo $result ? 'PARSED' : 'IGNORED';
+ }
+
+ /**
+ * Handle Gitlab webhooks
+ *
+ * @access public
+ */
+ public function gitlab()
+ {
+ if ($this->config->get('webhook_token') !== $this->request->getStringParam('token')) {
+ $this->response->text('Not Authorized', 401);
+ }
+
+ $this->gitlabWebhook->setProjectId($this->request->getIntegerParam('project_id'));
+
+ $result = $this->gitlabWebhook->parsePayload(
+ $this->request->getJson() ?: array()
);
echo $result ? 'PARSED' : 'IGNORED';