summaryrefslogtreecommitdiff
path: root/app/Integration/SendgridWebhook.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-13 13:17:16 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-13 13:17:16 -0400
commitf2abf339120751f11f729606b46927332f886a1d (patch)
tree46976ea48e812b18903b2bde2d84ab113bc0708f /app/Integration/SendgridWebhook.php
parent7ba9b2d9b9b8426aacabcb7e3e4a0c08d2be5444 (diff)
Add Sendgrid as mail transport
Diffstat (limited to 'app/Integration/SendgridWebhook.php')
-rw-r--r--app/Integration/SendgridWebhook.php74
1 files changed, 0 insertions, 74 deletions
diff --git a/app/Integration/SendgridWebhook.php b/app/Integration/SendgridWebhook.php
deleted file mode 100644
index 9125f00b..00000000
--- a/app/Integration/SendgridWebhook.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-
-namespace Integration;
-
-use HTML_To_Markdown;
-use Core\Tool;
-
-/**
- * Sendgrid Webhook
- *
- * @package integration
- * @author Frederic Guillot
- */
-class SendgridWebhook extends \Core\Base
-{
- /**
- * Parse incoming email
- *
- * @access public
- * @param array $payload Incoming email
- * @return boolean
- */
- public function parsePayload(array $payload)
- {
- if (empty($payload['envelope']) || empty($payload['subject'])) {
- return false;
- }
-
- $envelope = json_decode($payload['envelope'], true);
- $sender = isset($envelope['to'][0]) ? $envelope['to'][0] : '';
-
- // The user must exists in Kanboard
- $user = $this->user->getByEmail($envelope['from']);
-
- if (empty($user)) {
- $this->container['logger']->debug('SendgridWebhook: ignored => user not found');
- return false;
- }
-
- // The project must have a short name
- $project = $this->project->getByIdentifier(Tool::getMailboxHash($sender));
-
- if (empty($project)) {
- $this->container['logger']->debug('SendgridWebhook: 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('SendgridWebhook: ignored => user is not member of the project');
- return false;
- }
-
- // Get the Markdown contents
- if (! empty($payload['html'])) {
- $markdown = new HTML_To_Markdown($payload['html'], array('strip_tags' => true));
- $description = $markdown->output();
- }
- else if (! empty($payload['text'])) {
- $description = $payload['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'],
- ));
- }
-}