setDescription('Insert missing calendarchanges rows for existing events'); $this->addArgument( 'user', InputArgument::OPTIONAL, 'User to fix calendar sync tokens for, if omitted all users will be fixed', null, ); } public function execute(InputInterface $input, OutputInterface $output): int { $userArg = $input->getArgument('user'); if ($userArg !== null) { $user = $this->userManager->get($userArg); if ($user === null) { $output->writeln("User $userArg does not exist"); return 1; } $this->fixUserCalendars($user); } else { $progress = new ProgressBar($output); $this->userManager->callForSeenUsers(function (IUser $user) use ($progress) { $this->fixUserCalendars($user, $progress); }); $progress->finish(); } return 0; } private function fixUserCalendars(IUser $user, ?ProgressBar $progress = null): void { $calendars = $this->calDavBackend->getCalendarsForUser("principals/users/" . $user->getUID()); foreach ($calendars as $calendar) { $this->calDavBackend->restoreChanges($calendar['id']); } if ($progress !== null) { $progress->advance(); } } }