Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions apps/files_external/lib/Command/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use OCA\Files_External\Service\StoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\AppFramework\Http;
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\User\Exceptions\UserNotFoundException;
Expand All @@ -35,6 +36,7 @@ public function __construct(
private IUserManager $userManager,
private IUserSession $userSession,
private BackendService $backendService,
private IGroupManager $groupManager,
) {
parent::__construct();
}
Expand Down Expand Up @@ -76,6 +78,18 @@ protected function configure(): void {
'',
InputOption::VALUE_NONE,
'Don\'t save the created mount, only list the new mount'
)
->addOption(
'applicable-user',
'',
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
'Add a user as applicable to the newly created mount'
)
->addOption(
'applicable-group',
'',
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
'Add a group as applicable to the newly created mount'
);
parent::configure();
}
Expand All @@ -87,6 +101,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$storageIdentifier = $input->getArgument('storage_backend');
$authIdentifier = $input->getArgument('authentication_backend');
$configInput = $input->getOption('config');
$applicableUsers = $input->getOption('applicable-user');
$applicableGroups = $input->getOption('applicable-group');

$storageBackend = $this->backendService->getBackend($storageIdentifier);
$authBackend = $this->backendService->getAuthMechanism($authIdentifier);
Expand Down Expand Up @@ -129,6 +145,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$mount->setAuthMechanism($authBackend);
$mount->setBackendOptions($config);

foreach ($applicableUsers as $applicableUser) {
if (!$this->userManager->userExists($applicableUser)) {
$output->writeln('<error>Unknown user "' . $applicableUser . '"</error>');
}
}
foreach ($applicableGroups as $applicableGroup) {
if (!$this->groupManager->groupExists($applicableGroup)) {
$output->writeln('<error>Unknown group "' . $applicableGroup . '"</error>');
}
}
$mount->setApplicableUsers($applicableUsers);
$mount->setApplicableGroups($applicableGroups);

if ($user) {
if (!$this->userManager->userExists($user)) {
$output->writeln('<error>User "' . $user . '" not found</error>');
Expand Down
Loading