diff --git a/server/controllers/ticket/seen.php b/server/controllers/ticket/seen.php index a8eea7dc..7f41c1e7 100644 --- a/server/controllers/ticket/seen.php +++ b/server/controllers/ticket/seen.php @@ -18,6 +18,22 @@ class SeenController extends Controller { public function handler() { $ticketnumber = Controller::request('ticketNumber'); - + $user = Controller::getLoggedUser(); + $ticket = Ticket::getByTicketNumber($ticketnumber); + + if (Controller::isStaffLogged() && $ticket->owner_id === $user->id) { + $ticket->unreadStaff = false; + $ticket->store(); + Response::respondSuccess(); + return; + } + if (!Controller::isStaffLogged() && $user->id === $ticket->author_id) { + $ticket->unread = false; + $ticket->store(); + Response::respondSuccess(); + return; + } + Response::respondError(ERRORS::NO_PERMISSION); + } } \ No newline at end of file diff --git a/server/models/Ticket.php b/server/models/Ticket.php index b029b6a4..b12a6905 100644 --- a/server/models/Ticket.php +++ b/server/models/Ticket.php @@ -18,7 +18,8 @@ class Ticket extends DataStore { 'priority', 'author', 'owner', - 'ownTicketeventList' + 'ownTicketeventList', + 'unreadStaff' ); }