aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CardDAV/ImageExportPlugin.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/CardDAV/ImageExportPlugin.php')
-rw-r--r--apps/dav/lib/CardDAV/ImageExportPlugin.php40
1 files changed, 11 insertions, 29 deletions
diff --git a/apps/dav/lib/CardDAV/ImageExportPlugin.php b/apps/dav/lib/CardDAV/ImageExportPlugin.php
index 4caf234e346..74a8b032e42 100644
--- a/apps/dav/lib/CardDAV/ImageExportPlugin.php
+++ b/apps/dav/lib/CardDAV/ImageExportPlugin.php
@@ -1,29 +1,13 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Georg Ehrke <oc.list@georgehrke.com>
- * @author Jacob Neplokh <me@jacobneplokh.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\DAV\CardDAV;
+use OCP\AppFramework\Http;
use OCP\Files\NotFoundException;
use Sabre\CardDAV\Card;
use Sabre\DAV\Server;
@@ -35,16 +19,15 @@ class ImageExportPlugin extends ServerPlugin {
/** @var Server */
protected $server;
- /** @var PhotoCache */
- private $cache;
/**
* ImageExportPlugin constructor.
*
* @param PhotoCache $cache
*/
- public function __construct(PhotoCache $cache) {
- $this->cache = $cache;
+ public function __construct(
+ private PhotoCache $cache,
+ ) {
}
/**
@@ -77,7 +60,7 @@ class ImageExportPlugin extends ServerPlugin {
$path = $request->getPath();
$node = $this->server->tree->getNodeForPath($path);
- if (!($node instanceof Card)) {
+ if (!$node instanceof Card) {
return true;
}
@@ -98,18 +81,17 @@ class ImageExportPlugin extends ServerPlugin {
$response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate');
$response->setHeader('Etag', $node->getETag());
- $response->setHeader('Pragma', 'public');
try {
$file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node);
$response->setHeader('Content-Type', $file->getMimeType());
$fileName = $node->getName() . '.' . PhotoCache::ALLOWED_CONTENT_TYPES[$file->getMimeType()];
$response->setHeader('Content-Disposition', "attachment; filename=$fileName");
- $response->setStatus(200);
+ $response->setStatus(Http::STATUS_OK);
$response->setBody($file->getContent());
} catch (NotFoundException $e) {
- $response->setStatus(404);
+ $response->setStatus(Http::STATUS_NO_CONTENT);
}
return false;