Set Last Modified to notes response..

This commit is contained in:
Matias De lellis
2020-06-15 11:50:32 -03:00
parent d8d188af4b
commit c4c9984bba

View File

@@ -54,8 +54,13 @@ class NoteController extends Controller {
$notes = $this->noteService->getAll($this->userId);
$etag = md5(json_encode($notes));
$lastModified = new \DateTime(null, new \DateTimeZone('GMT'));
$timestamp = max(array_map(function($note) { return $note->getTimestamp(); }, $notes));
$lastModified->setTimestamp($timestamp);
$response = new JSONResponse($notes);
$response->setETag($etag);
$response->setLastModified($lastModified);
return $response;
}