Skip to content
This repository has been archived by the owner on Apr 5, 2020. It is now read-only.

Commit

Permalink
Include dependency HtmlToMarkdown
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed Jan 8, 2016
1 parent 3d0eb7e commit 18d460d
Show file tree
Hide file tree
Showing 42 changed files with 2,552 additions and 7 deletions.
6 changes: 5 additions & 1 deletion EmailHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace Kanboard\Plugin\Mailgun;

require_once __DIR__.'/vendor/autoload.php';

use Kanboard\Core\Base;
use Kanboard\Core\Tool;
use Kanboard\Core\Mail\ClientInterface;
use League\HTMLToMarkdown\HtmlConverter;

defined('MAILGUN_API_TOKEN') or define('MAILGUN_API_TOKEN', '');
defined('MAILGUN_DOMAIN') or define('MAILGUN_DOMAIN', '');
Expand Down Expand Up @@ -80,7 +83,8 @@ public function receiveEmail(array $payload)

// Get the Markdown contents
if (! empty($payload['stripped-html'])) {
$description = $this->htmlConverter->convert($payload['stripped-html']);
$htmlConverter = new HtmlConverter(array('strip_tags' => true));
$description = $htmlConverter->convert($payload['stripped-html']);
}
else if (! empty($payload['stripped-text'])) {
$description = $payload['stripped-text'];
Expand Down
2 changes: 1 addition & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getPluginAuthor()

public function getPluginVersion()
{
return '1.0.1';
return '1.0.2';
}

public function getPluginHomepage()
Expand Down
11 changes: 6 additions & 5 deletions Test/EmailHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskFinder;
use Kanboard\Model\Project;
use Kanboard\Model\ProjectPermission;
use Kanboard\Model\ProjectUserRole;
use Kanboard\Model\User;
use Kanboard\Core\Security\Role;

class EmailHandlerTest extends Base
{
Expand Down Expand Up @@ -35,7 +36,7 @@ public function testHandlePayload()
{
$w = new EmailHandler($this->container);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$pp = new ProjectUserRole($this->container);
$u = new User($this->container);
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
Expand All @@ -56,16 +57,16 @@ public function testHandlePayload()

// User is not member
$this->assertFalse($w->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo')));
$this->assertTrue($pp->addMember(2, 2));
$this->assertTrue($pp->addUser(2, 2, Role::PROJECT_MEMBER));

// The task must be created
$this->assertTrue($w->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo')));
$this->assertTrue($w->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-html' => '<strong>boo</strong>')));

$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(2, $task['project_id']);
$this->assertEquals('Email task', $task['title']);
$this->assertEquals('boo', $task['description']);
$this->assertEquals('**boo**', $task['description']);
$this->assertEquals(2, $task['creator_id']);
}
}
19 changes: 19 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "kanboard/plugin-mailgun",
"type": "project",
"license": "MIT",
"authors": [
{
"name": "Frédéric Guillot"
}
],
"config": {
"preferred-install": "dist",
"optimize-autoloader": true,
"discard-changes": true
},
"require" : {
"php" : ">=5.3",
"league/html-to-markdown" : "~4.0"
}
}
85 changes: 85 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions vendor/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInitf288f142dd31f9a3a64306fe8906c32d::getLoader();
1 change: 1 addition & 0 deletions vendor/bin/html-to-markdown
Loading

0 comments on commit 18d460d

Please sign in to comment.