Creates ticket session when an unlogged user creates a ticket.

Fixes runtime error when there is no author associated with a log.
This commit is contained in:
Maxi Redigonda 2019-11-08 10:41:50 -03:00
parent bedf55d1ad
commit a883f4d430
2 changed files with 9 additions and 3 deletions

View File

@ -115,10 +115,16 @@ class CreateController extends Controller {
}
}
Log::createLog('CREATE_TICKET', $this->ticketNumber);
Response::respondSuccess([
'ticketNumber' => $this->ticketNumber
]);
if(!Controller::isUserSystemEnabled() && !Controller::isStaffLogged()) {
$session = Session::getInstance();
$session->createTicketSession($this->ticketNumber);
}
Log::createLog('CREATE_TICKET', $this->ticketNumber);
}
private function storeTicket() {

View File

@ -30,7 +30,7 @@ class Log extends DataStore {
public static function createLog($type, $to, $author = null) {
$session = Session::getInstance();
$authorName = '';
if($session->isTicketSession()) {
$ticketNumber = $session->getTicketNumber();
$ticket = Ticket::getByTicketNumber($ticketNumber);
@ -68,7 +68,7 @@ class Log extends DataStore {
'to' => $this->to,
'author' => [
'name' => $this->authorName,
'id' => !$author->isNull() ? $author->id : null,
'id' => $author && !$author->isNull() ? $author->id : null,
'staff' => $author instanceof Staff
],
'date' => $this->date