This repository has been archived by the owner on Apr 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to override sender E-Mail
- Loading branch information
Showing
6 changed files
with
74 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h3><img src="<?= $this->url->dir() ?>plugins/Mailgun/mailgun-icon.png"/> Mailgun</h3> | ||
<div class="panel"> | ||
<?= $this->form->label(t('Catch-All Email Address'), 'mailgun_catch_all') ?> | ||
<?= $this->form->email('mailgun_catch_all', $values) ?> | ||
|
||
<p class="form-help"> | ||
<?= t('Blank value will cause unknown senders to be ignored') ?> - | ||
<a href="https://github.com/kanboard/plugin-mailgun#installation" target="_blank"><?= t('Help on Mailgun integration') ?></a> | ||
</p> | ||
|
||
<div class="form-actions"> | ||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
use Kanboard\Plugin\Mailgun\EmailHandler; | ||
use Kanboard\Model\TaskFinderModel; | ||
use Kanboard\Model\ProjectModel; | ||
use Kanboard\Model\ProjectMetadataModel; | ||
use Kanboard\Model\ProjectUserRoleModel; | ||
use Kanboard\Model\UserModel; | ||
use Kanboard\Core\Security\Role; | ||
|
@@ -116,6 +117,38 @@ public function testHandlePayload() | |
$this->assertEquals(2, $task['creator_id']); | ||
} | ||
|
||
public function testHandlePayloadFromAnyone() | ||
{ | ||
$emailHandler = new EmailHandler($this->container); | ||
$projectModel = new ProjectModel($this->container); | ||
$projectUserRoleModel = new ProjectUserRoleModel($this->container); | ||
$userModel = new UserModel($this->container); | ||
$taskFinderModel = new TaskFinderModel($this->container); | ||
$projectMetadataModel = new ProjectMetadataModel($this->container); | ||
|
||
$this->assertEquals(2, $userModel->create(array('username' => 'anyone', 'email' => 'anyone@localhost'))); | ||
|
||
$this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); | ||
$this->assertEquals(2, $projectModel->create(array('name' => 'test2', 'email' => 'test2@localhost'))); | ||
|
||
// Allow project 2 to receive E-Mail from any sender | ||
$this->assertTrue($projectMetadataModel->save(2, array('mailgun_catch_all' => 'anyone@localhost'))); | ||
|
||
// Message is from a user not in a project - and should be mapped to the project user | ||
$this->assertFalse($emailHandler->receiveEmail(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'test2@localhost', 'stripped-text' => 'boo'))); | ||
$this->assertTrue($projectUserRoleModel->addUser(2, 2, Role::PROJECT_MEMBER)); | ||
|
||
// The task must be created | ||
$this->assertTrue($emailHandler->receiveEmail(array('sender' => '[email protected]', 'subject' => 'Email task', 'recipient' => 'test2@localhost', 'stripped-html' => '<strong>boo</strong>'))); | ||
|
||
$task = $taskFinderModel->getById(1); | ||
$this->assertNotEmpty($task); | ||
$this->assertEquals(2, $task['project_id']); | ||
$this->assertEquals('Email task', $task['title']); | ||
$this->assertEquals('**boo**', $task['description']); | ||
$this->assertEquals(2, $task['creator_id']); | ||
} | ||
|
||
public function testGetSubject() | ||
{ | ||
$handler = new EmailHandler($this->container); | ||
|