summaryrefslogtreecommitdiff
path: root/app/Integration/MailgunWebhook.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-07 22:17:50 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-07 22:17:50 -0400
commite22da9d32addefa8d739171febcf6f6d0c06ba7b (patch)
treeaffb9f8729ac9d4f07dd7f24dff39bfaa9cda0ff /app/Integration/MailgunWebhook.php
parent4f32352fe62e47ad5ea760eb00493bdc061b2407 (diff)
Add Mailgun API as mail transport
Diffstat (limited to 'app/Integration/MailgunWebhook.php')
-rw-r--r--app/Integration/MailgunWebhook.php71
1 files changed, 0 insertions, 71 deletions
diff --git a/app/Integration/MailgunWebhook.php b/app/Integration/MailgunWebhook.php
deleted file mode 100644
index 50d96a4a..00000000
--- a/app/Integration/MailgunWebhook.php
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-
-namespace Integration;
-
-use HTML_To_Markdown;
-use Core\Tool;
-
-/**
- * Mailgun Webhook
- *
- * @package integration
- * @author Frederic Guillot
- */
-class MailgunWebhook extends \Core\Base
-{
- /**
- * Parse incoming email
- *
- * @access public
- * @param array $payload Incoming email
- * @return boolean
- */
- public function parsePayload(array $payload)
- {
- if (empty($payload['sender']) || empty($payload['subject']) || empty($payload['recipient'])) {
- return false;
- }
-
- // The user must exists in Kanboard
- $user = $this->user->getByEmail($payload['sender']);
-
- if (empty($user)) {
- $this->container['logger']->debug('MailgunWebhook: ignored => user not found');
- return false;
- }
-
- // The project must have a short name
- $project = $this->project->getByIdentifier(Tool::getMailboxHash($payload['recipient']));
-
- if (empty($project)) {
- $this->container['logger']->debug('MailgunWebhook: ignored => project not found');
- return false;
- }
-
- // The user must be member of the project
- if (! $this->projectPermission->isMember($project['id'], $user['id'])) {
- $this->container['logger']->debug('MailgunWebhook: ignored => user is not member of the project');
- return false;
- }
-
- // Get the Markdown contents
- if (! empty($payload['stripped-html'])) {
- $markdown = new HTML_To_Markdown($payload['stripped-html'], array('strip_tags' => true));
- $description = $markdown->output();
- }
- else if (! empty($payload['stripped-text'])) {
- $description = $payload['stripped-text'];
- }
- else {
- $description = '';
- }
-
- // Finally, we create the task
- return (bool) $this->taskCreation->create(array(
- 'project_id' => $project['id'],
- 'title' => $payload['subject'],
- 'description' => $description,
- 'creator_id' => $user['id'],
- ));
- }
-}