Resend email endpoint appears to be working...need to do further tests first though

This commit is contained in:
Mike Koch 2017-05-03 13:02:36 -04:00
parent 69676232e3
commit 7c144df494
3 changed files with 10 additions and 3 deletions

View File

@ -221,7 +221,7 @@ class EmailTemplateParser {
$msg = str_replace('%%PRIORITY%%', $priority, $msg); $msg = str_replace('%%PRIORITY%%', $priority, $msg);
$msg = str_replace('%%OWNER%%', $owner, $msg); $msg = str_replace('%%OWNER%%', $owner, $msg);
$msg = str_replace('%%STATUS%%', $statusName, $msg); $msg = str_replace('%%STATUS%%', $statusName, $msg);
$msg = str_replace('%%EMAIL%%', $ticket->email, $msg); $msg = str_replace('%%EMAIL%%', implode(';',$ticket->email), $msg);
$msg = str_replace('%%CREATED%%', $ticket->dateCreated, $msg); $msg = str_replace('%%CREATED%%', $ticket->dateCreated, $msg);
$msg = str_replace('%%UPDATED%%', $ticket->lastChanged, $msg); $msg = str_replace('%%UPDATED%%', $ticket->lastChanged, $msg);
$msg = str_replace('%%ID%%', $ticket->id, $msg); $msg = str_replace('%%ID%%', $ticket->id, $msg);

View File

@ -40,8 +40,10 @@ class ResendTicketEmailToCustomerController extends InternalApiController {
} }
$reply = null; $reply = null;
$emailTemplate = EmailTemplateRetriever::NEW_TICKET;
if (isset($_GET['replyId'])) { if (isset($_GET['replyId'])) {
$replyId = $_GET['replyId']; $replyId = $_GET['replyId'];
$emailTemplate = EmailTemplateRetriever::NEW_REPLY_BY_STAFF;
foreach ($ticket->replies as $ticketReply) { foreach ($ticket->replies as $ticketReply) {
if ($ticketReply->id === $replyId) { if ($ticketReply->id === $replyId) {
@ -63,6 +65,8 @@ class ResendTicketEmailToCustomerController extends InternalApiController {
$addressees = new Addressees(); $addressees = new Addressees();
$addressees->to = $ticket->email; $addressees->to = $ticket->email;
$emailSender->sendEmailForTicket(EmailTemplateRetriever::NEW_REPLY_BY_STAFF, $language, $addressees, $ticket, $hesk_settings, $modsForHeskSettings); $emailSender->sendEmailForTicket($emailTemplate, $language, $addressees, $ticket, $hesk_settings, $modsForHeskSettings);
http_response_code(204);
} }
} }

View File

@ -142,6 +142,9 @@ function getLoggingLocation($exception) {
$trace = $exception->getTrace(); $trace = $exception->getTrace();
$lastCall = $trace[0]; $lastCall = $trace[0];
$location = basename($lastCall['file'], '.php'); $location = basename($lastCall['file'], '.php');
if ($location === null || trim($location) === '') {
$location = 'N/A';
}
return "REST API: {$location}"; return "REST API: {$location}";
} }
@ -182,7 +185,7 @@ Link::all(array(
/* Internal use only routes */ /* Internal use only routes */
// Resend email response // Resend email response
'/v1/staff/tickets/{i}/resend-email' => \Controllers\Tickets\ResendTicketEmailToCustomerController::class, '/v1-internal/staff/tickets/{i}/resend-email' => \Controllers\Tickets\ResendTicketEmailToCustomerController::class,
// Any URL that doesn't match goes to the 404 handler // Any URL that doesn't match goes to the 404 handler
'404' => 'handle404' '404' => 'handle404'