1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-11-29 11:24:11 +01:00

Allow address book list to be cached.

This commit is contained in:
Thomas Tanghus 2013-09-10 07:17:05 +02:00
parent 5bc8e08c6c
commit 5f17dc9b5e

View File

@ -30,13 +30,24 @@ class AddressBookController extends BaseController {
$app = new App($this->api->getUserId());
$addressBooks = $app->getAddressBooksForUser();
$response = array();
$lastModified = 0;
foreach($addressBooks as $addressBook) {
$response[] = $addressBook->getMetaData();
$data = $addressBook->getMetaData();
$response[] = $data;
if(!is_null($data['lastmodified'])) {
$lastModified = max($lastModified, $data['lastmodified']);
}
$response = new JSONResponse(
array(
}
$response = new JSONResponse(array(
'addressbooks' => $response,
));
if($lastModified > 0) {
$response->setLastModified(\DateTime::createFromFormat('U', $lastModified) ?: null);
$response->setETag(md5($lastModified));
}
return $response;
}