From ac86c3100a1030026024c33c1cf02ec79f08ff51 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 19 Apr 2015 16:01:41 -0400 Subject: Add Mailgun integration (incoming emails) --- app/Controller/Webhook.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'app/Controller') diff --git a/app/Controller/Webhook.php b/app/Controller/Webhook.php index afa0543a..06bfcd4e 100644 --- a/app/Controller/Webhook.php +++ b/app/Controller/Webhook.php @@ -112,8 +112,20 @@ class Webhook extends Base $this->response->text('Not Authorized', 401); } - $result = $this->postmarkWebhook->parsePayload($this->request->getJson() ?: array()); + echo $this->postmarkWebhook->parsePayload($this->request->getJson() ?: array()) ? 'PARSED' : 'IGNORED'; + } - echo $result ? 'PARSED' : 'IGNORED'; + /** + * Handle Mailgun webhooks + * + * @access public + */ + public function mailgun() + { + if ($this->config->get('webhook_token') !== $this->request->getStringParam('token')) { + $this->response->text('Not Authorized', 401); + } + + echo $this->mailgunWebhook->parsePayload($_POST) ? 'PARSED' : 'IGNORED'; } } -- cgit v1.2.3