diff options
Diffstat (limited to 'apps/files/lib/Capabilities.php')
-rw-r--r-- | apps/files/lib/Capabilities.php | 84 |
1 files changed, 29 insertions, 55 deletions
diff --git a/apps/files/lib/Capabilities.php b/apps/files/lib/Capabilities.php index 29abfb5b253..6b50e5807a5 100644 --- a/apps/files/lib/Capabilities.php +++ b/apps/files/lib/Capabilities.php @@ -1,76 +1,50 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Christopher Schäpers <kondou@ts.unde.re> - * @author Joas Schilling <coding@schilljs.com> - * @author Julius Härtl <jus@bitgrid.net> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Tom Needham <tom@owncloud.com> - * - * @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\Files; -use OCA\Files\Service\DirectEditingService; +use OC\Files\FilenameValidator; +use OCA\Files\Service\ChunkedUploadConfig; use OCP\Capabilities\ICapability; -use OCP\IConfig; -use OCP\IURLGenerator; +use OCP\Files\Conversion\ConversionMimeProvider; +use OCP\Files\Conversion\IConversionManager; -/** - * Class Capabilities - * - * @package OCA\Files - */ class Capabilities implements ICapability { - /** @var IConfig */ - protected $config; - - /** @var DirectEditingService */ - protected $directEditingService; - - /** @var IURLGenerator */ - private $urlGenerator; - - /** - * Capabilities constructor. - * - * @param IConfig $config - */ - public function __construct(IConfig $config, DirectEditingService $directEditingService, IURLGenerator $urlGenerator) { - $this->config = $config; - $this->directEditingService = $directEditingService; - $this->urlGenerator = $urlGenerator; + public function __construct( + protected FilenameValidator $filenameValidator, + protected IConversionManager $fileConversionManager, + ) { } /** * Return this classes capabilities * - * @return array + * @return array{files: array{'$comment': ?string, bigfilechunking: bool, blacklisted_files: list<mixed>, forbidden_filenames: list<string>, forbidden_filename_basenames: list<string>, forbidden_filename_characters: list<string>, forbidden_filename_extensions: list<string>, chunked_upload: array{max_size: int, max_parallel_count: int}, file_conversions: list<array{from: string, to: string, extension: string, displayName: string}>}} */ - public function getCapabilities() { + public function getCapabilities(): array { return [ 'files' => [ + '$comment' => '"blacklisted_files" is deprecated as of Nextcloud 30, use "forbidden_filenames" instead', + 'blacklisted_files' => $this->filenameValidator->getForbiddenFilenames(), + 'forbidden_filenames' => $this->filenameValidator->getForbiddenFilenames(), + 'forbidden_filename_basenames' => $this->filenameValidator->getForbiddenBasenames(), + 'forbidden_filename_characters' => $this->filenameValidator->getForbiddenCharacters(), + 'forbidden_filename_extensions' => $this->filenameValidator->getForbiddenExtensions(), + 'bigfilechunking' => true, - 'blacklisted_files' => $this->config->getSystemValue('blacklisted_files', ['.htaccess']), - 'directEditing' => [ - 'url' => $this->urlGenerator->linkToOCSRouteAbsolute('files.DirectEditing.info'), - 'etag' => $this->directEditingService->getDirectEditingETag() - ] + 'chunked_upload' => [ + 'max_size' => ChunkedUploadConfig::getMaxChunkSize(), + 'max_parallel_count' => ChunkedUploadConfig::getMaxParallelCount(), + ], + + 'file_conversions' => array_map(function (ConversionMimeProvider $mimeProvider) { + return $mimeProvider->jsonSerialize(); + }, $this->fileConversionManager->getProviders()), ], ]; } |