diff --git a/api/src/Service/LogService.php b/api/src/Service/LogService.php index 39283108e..abdc3a8c9 100644 --- a/api/src/Service/LogService.php +++ b/api/src/Service/LogService.php @@ -170,11 +170,15 @@ public function saveLog(Request $request, Response $response = null, int $stopWa */ private function removeUnreads(Log $callLog) { - if ($callLog->getResponseStatusCode() === 200 && !empty($callLog->getEndpoint()) + if ( + $callLog->getResponseStatusCode() === 200 && + !empty($callLog->getEndpoint()) && $callLog->getUserId() !== null && !empty($callLog->getObjectId()) && strtolower($callLog->getRequestMethod()) === 'get' && - (strtolower($callLog->getEndpoint()->getMethod()) === 'get') || - in_array('get', array_map('strtolower', $callLog->getEndpoint()->getMethods()))) { + ( + strtolower($callLog->getEndpoint()->getMethod()) === 'get' || + in_array('get', array_map('strtolower', $callLog->getEndpoint()->getMethods())) + )) { // Check if there exist Unread objects for this Object+User. If so, delete them. $object = $this->entityManager->getRepository('App:ObjectEntity')->find($callLog->getObjectId()); if ($object instanceof ObjectEntity) {