aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Command/FixCalendarSyncCommand.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/Command/FixCalendarSyncCommand.php')
-rw-r--r--apps/dav/lib/Command/FixCalendarSyncCommand.php37
1 files changed, 12 insertions, 25 deletions
diff --git a/apps/dav/lib/Command/FixCalendarSyncCommand.php b/apps/dav/lib/Command/FixCalendarSyncCommand.php
index 6db32ff6d5e..cb31355c10d 100644
--- a/apps/dav/lib/Command/FixCalendarSyncCommand.php
+++ b/apps/dav/lib/Command/FixCalendarSyncCommand.php
@@ -2,25 +2,9 @@
declare(strict_types=1);
-/*
- * @copyright 2024 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2024 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\DAV\Command;
@@ -36,8 +20,10 @@ use Symfony\Component\Console\Output\OutputInterface;
class FixCalendarSyncCommand extends Command {
- public function __construct(private IUserManager $userManager,
- private CalDavBackend $calDavBackend) {
+ public function __construct(
+ private IUserManager $userManager,
+ private CalDavBackend $calDavBackend,
+ ) {
parent::__construct('dav:fix-missing-caldav-changes');
}
@@ -57,22 +43,23 @@ class FixCalendarSyncCommand extends Command {
$user = $this->userManager->get($userArg);
if ($user === null) {
$output->writeln("<error>User $userArg does not exist</error>");
- return 1;
+ return self::FAILURE;
}
$this->fixUserCalendars($user);
} else {
$progress = new ProgressBar($output);
- $this->userManager->callForSeenUsers(function (IUser $user) use ($progress) {
+ $this->userManager->callForSeenUsers(function (IUser $user) use ($progress): void {
$this->fixUserCalendars($user, $progress);
});
$progress->finish();
}
- return 0;
+ $output->writeln('');
+ return self::SUCCESS;
}
private function fixUserCalendars(IUser $user, ?ProgressBar $progress = null): void {
- $calendars = $this->calDavBackend->getCalendarsForUser("principals/users/" . $user->getUID());
+ $calendars = $this->calDavBackend->getCalendarsForUser('principals/users/' . $user->getUID());
foreach ($calendars as $calendar) {
$this->calDavBackend->restoreChanges($calendar['id']);