summaryrefslogtreecommitdiff
path: root/app/Controller/Webhook.php
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/Webhook.php
parentd6530bd55fdd863f0cf153bc2854fb4e34076316 (diff)
Add Gitlab webhook
Diffstat (limited to 'app/Controller/Webhook.php')
-rw-r--r--app/Controller/Webhook.php22
1 files changed, 21 insertions, 1 deletions
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';