aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Command/ListCommand.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/lib/Command/ListCommand.php')
-rw-r--r--apps/files_external/lib/Command/ListCommand.php71
1 files changed, 25 insertions, 46 deletions
diff --git a/apps/files_external/lib/Command/ListCommand.php b/apps/files_external/lib/Command/ListCommand.php
index b2a4baf366b..350916b6c2c 100644
--- a/apps/files_external/lib/Command/ListCommand.php
+++ b/apps/files_external/lib/Command/ListCommand.php
@@ -1,27 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Daniel Kesselberg <mail@danielkesselberg.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Robin Appelman <robin@icewind.nl>
- * @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: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Command;
@@ -29,6 +11,7 @@ use OC\Core\Command\Base;
use OC\User\NoUserException;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\GlobalStoragesService;
+use OCA\Files_External\Service\StoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\IUserManager;
use OCP\IUserSession;
@@ -39,19 +22,15 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class ListCommand extends Base {
- protected GlobalStoragesService $globalService;
- protected UserStoragesService $userService;
- protected IUserSession $userSession;
- protected IUserManager $userManager;
-
public const ALL = -1;
- public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
+ public function __construct(
+ protected GlobalStoragesService $globalService,
+ protected UserStoragesService $userService,
+ protected IUserSession $userSession,
+ protected IUserManager $userManager,
+ ) {
parent::__construct();
- $this->globalService = $globalService;
- $this->userService = $userService;
- $this->userSession = $userSession;
- $this->userManager = $userManager;
}
protected function configure(): void {
@@ -93,7 +72,7 @@ class ListCommand extends Base {
}
$this->listMounts($userId, $mounts, $input, $output);
- return 0;
+ return self::SUCCESS;
}
/**
@@ -107,11 +86,11 @@ class ListCommand extends Base {
$output->writeln('[]');
} else {
if ($userId === self::ALL) {
- $output->writeln("<info>No mounts configured</info>");
+ $output->writeln('<info>No mounts configured</info>');
} elseif ($userId) {
$output->writeln("<info>No mounts configured by $userId</info>");
} else {
- $output->writeln("<info>No admin mounts configured</info>");
+ $output->writeln('<info>No admin mounts configured</info>');
}
}
return;
@@ -128,12 +107,12 @@ class ListCommand extends Base {
}
if (!$input->getOption('show-password')) {
- $hideKeys = ['password', 'refresh_token', 'token', 'client_secret', 'public_key', 'private_key'];
+ $hideKeys = ['key', 'bucket', 'secret', 'password', 'refresh_token', 'token', 'client_secret', 'public_key', 'private_key'];
foreach ($mounts as $mount) {
$config = $mount->getBackendOptions();
foreach ($config as $key => $value) {
if (in_array($key, $hideKeys)) {
- $mount->setBackendOption($key, '***');
+ $mount->setBackendOption($key, '***REMOVED SENSITIVE VALUE***');
}
}
}
@@ -245,16 +224,16 @@ class ListCommand extends Base {
}
}
- protected function getStorageService($userId) {
- if (!empty($userId)) {
- $user = $this->userManager->get($userId);
- if (is_null($user)) {
- throw new NoUserException("user $userId not found");
- }
- $this->userSession->setUser($user);
- return $this->userService;
- } else {
+ protected function getStorageService(string $userId): StoragesService {
+ if (empty($userId)) {
return $this->globalService;
}
+
+ $user = $this->userManager->get($userId);
+ if (is_null($user)) {
+ throw new NoUserException("user $userId not found");
+ }
+ $this->userSession->setUser($user);
+ return $this->userService;
}
}