Working on more email stuff

This commit is contained in:
Mike Koch 2017-03-04 21:59:55 -05:00
parent 2a6766c10e
commit 672d089b20
4 changed files with 27 additions and 2 deletions

View File

@ -47,6 +47,17 @@ class EmailSenderHelper {
$emailBuilder->cc = $addressees->cc; $emailBuilder->cc = $addressees->cc;
$emailBuilder->bcc = $addressees->bcc; $emailBuilder->bcc = $addressees->bcc;
foreach ($heskSettings['custom_fields'] as $k => $v) {
$number = intval(str_replace('custom', '', $k));
if ($v['use'] && $v['type'] == 'email' && !empty($ticket->customFields[$number])) {
if ($v['value']['email_type'] == 'cc') {
$emailBuilder->cc[] = $ticket->customFields[$number];
} elseif ($v['value']['email_type'] == 'bcc') {
$emailBuilder->bcc[] = $ticket->customFields[$number];
}
}
}
if ($modsForHeskSettings['attachments']) { if ($modsForHeskSettings['attachments']) {
$emailBuilder->attachments = $ticket->attachments; $emailBuilder->attachments = $ticket->attachments;
} }

View File

@ -2,6 +2,7 @@
namespace BusinessLogic\Tickets; namespace BusinessLogic\Tickets;
use BusinessLogic\Emails\EmailSenderHelper;
use BusinessLogic\Exceptions\ValidationException; use BusinessLogic\Exceptions\ValidationException;
use BusinessLogic\Statuses\DefaultStatusForAction; use BusinessLogic\Statuses\DefaultStatusForAction;
use DataAccess\Statuses\StatusGateway; use DataAccess\Statuses\StatusGateway;
@ -38,13 +39,20 @@ class TicketCreator {
*/ */
private $verifiedEmailChecker; private $verifiedEmailChecker;
function __construct($newTicketValidator, $trackingIdGenerator, $autoassigner, $statusGateway, $ticketGateway, $verifiedEmailChecker) { /**
* @var $emailSenderHelper EmailSenderHelper
*/
private $emailSenderHelper;
function __construct($newTicketValidator, $trackingIdGenerator, $autoassigner,
$statusGateway, $ticketGateway, $verifiedEmailChecker, $emailSenderHelper) {
$this->newTicketValidator = $newTicketValidator; $this->newTicketValidator = $newTicketValidator;
$this->trackingIdGenerator = $trackingIdGenerator; $this->trackingIdGenerator = $trackingIdGenerator;
$this->autoassigner = $autoassigner; $this->autoassigner = $autoassigner;
$this->statusGateway = $statusGateway; $this->statusGateway = $statusGateway;
$this->ticketGateway = $ticketGateway; $this->ticketGateway = $ticketGateway;
$this->verifiedEmailChecker = $verifiedEmailChecker; $this->verifiedEmailChecker = $verifiedEmailChecker;
$this->emailSenderHelper = $emailSenderHelper;
} }
/** /**

View File

@ -41,7 +41,9 @@ class EmailSenderHelperTest extends TestCase {
$this->emailTemplateParser = $this->createMock(EmailTemplateParser::class); $this->emailTemplateParser = $this->createMock(EmailTemplateParser::class);
$this->basicEmailSender = $this->createMock(BasicEmailSender::class); $this->basicEmailSender = $this->createMock(BasicEmailSender::class);
$this->mailgunEmailSender = $this->createMock(MailgunEmailSender::class); $this->mailgunEmailSender = $this->createMock(MailgunEmailSender::class);
$this->heskSettings = array(); $this->heskSettings = array(
'custom_fields' => array()
);
$this->modsForHeskSettings = array( $this->modsForHeskSettings = array(
'attachments' => 0, 'attachments' => 0,
'use_mailgun' => 0, 'use_mailgun' => 0,

View File

@ -246,4 +246,8 @@ class CreateTicketTest extends TestCase {
//-- Act //-- Act
$this->ticketCreator->createTicketByCustomer($this->ticketRequest, $this->heskSettings, $this->modsForHeskSettings, $this->userContext); $this->ticketCreator->createTicketByCustomer($this->ticketRequest, $this->heskSettings, $this->modsForHeskSettings, $this->userContext);
} }
function testItSendsAnEmailToTheCustomerWhenTheTicketIsCreated() {
//--
}
} }