diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-06-13 13:17:16 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-06-13 13:17:16 -0400 |
commit | f2abf339120751f11f729606b46927332f886a1d (patch) | |
tree | 46976ea48e812b18903b2bde2d84ab113bc0708f /app/Controller/Webhook.php | |
parent | 7ba9b2d9b9b8426aacabcb7e3e4a0c08d2be5444 (diff) |
Add Sendgrid as mail transport
Diffstat (limited to 'app/Controller/Webhook.php')
-rw-r--r-- | app/Controller/Webhook.php | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/app/Controller/Webhook.php b/app/Controller/Webhook.php index 10a24e47..d04f83b3 100644 --- a/app/Controller/Webhook.php +++ b/app/Controller/Webhook.php @@ -17,9 +17,7 @@ class Webhook extends Base */ public function task() { - if ($this->config->get('webhook_token') !== $this->request->getStringParam('token')) { - $this->response->text('Not Authorized', 401); - } + $this->checkWebhookToken(); $defaultProject = $this->project->getFirst(); @@ -49,9 +47,7 @@ class Webhook extends Base */ public function github() { - if ($this->config->get('webhook_token') !== $this->request->getStringParam('token')) { - $this->response->text('Not Authorized', 401); - } + $this->checkWebhookToken(); $this->githubWebhook->setProjectId($this->request->getIntegerParam('project_id')); @@ -70,15 +66,10 @@ class Webhook extends Base */ public function gitlab() { - if ($this->config->get('webhook_token') !== $this->request->getStringParam('token')) { - $this->response->text('Not Authorized', 401); - } + $this->checkWebhookToken(); $this->gitlabWebhook->setProjectId($this->request->getIntegerParam('project_id')); - - $result = $this->gitlabWebhook->parsePayload( - $this->request->getJson() ?: array() - ); + $result = $this->gitlabWebhook->parsePayload($this->request->getJson() ?: array()); echo $result ? 'PARSED' : 'IGNORED'; } @@ -90,12 +81,9 @@ class Webhook extends Base */ public function bitbucket() { - if ($this->config->get('webhook_token') !== $this->request->getStringParam('token')) { - $this->response->text('Not Authorized', 401); - } + $this->checkWebhookToken(); $this->bitbucketWebhook->setProjectId($this->request->getIntegerParam('project_id')); - $result = $this->bitbucketWebhook->parsePayload(json_decode(@$_POST['payload'], true) ?: array()); echo $result ? 'PARSED' : 'IGNORED'; @@ -108,10 +96,7 @@ class Webhook extends Base */ public function postmark() { - if ($this->config->get('webhook_token') !== $this->request->getStringParam('token')) { - $this->response->text('Not Authorized', 401); - } - + $this->checkWebhookToken(); echo $this->postmark->receiveEmail($this->request->getJson() ?: array()) ? 'PARSED' : 'IGNORED'; } @@ -122,10 +107,7 @@ class Webhook extends Base */ public function mailgun() { - if ($this->config->get('webhook_token') !== $this->request->getStringParam('token')) { - $this->response->text('Not Authorized', 401); - } - + $this->checkWebhookToken(); echo $this->mailgun->receiveEmail($_POST) ? 'PARSED' : 'IGNORED'; } @@ -136,10 +118,7 @@ class Webhook extends Base */ public function sendgrid() { - if ($this->config->get('webhook_token') !== $this->request->getStringParam('token')) { - $this->response->text('Not Authorized', 401); - } - - echo $this->sendgridWebhook->parsePayload($_POST) ? 'PARSED' : 'IGNORED'; + $this->checkWebhookToken(); + echo $this->sendgrid->receiveEmail($_POST) ? 'PARSED' : 'IGNORED'; } } |