setName('mail:repair:system-autoresponders'); $this->setDescription('Update sieve scripts of all accounts that follow the system out-of-office period'); } protected function execute(InputInterface $input, OutputInterface $output): int { foreach ($this->mailAccountMapper->findAllWhereOooFollowsSystem() as $mailAccount) { $accountId = $mailAccount->getId(); $userId = $mailAccount->getUserId(); $output->writeln("Updating account $accountId of user $userId"); $userId = $mailAccount->getUserId(); $user = $this->userManager->get($userId); if ($user === null) { $output->writeln("User $userId does not exist. Skipping ..."); continue; } $state = $this->outOfOfficeService->updateFromSystem($mailAccount, $user); if ($state === null) { $output->writeln( "Disabled autoresponder of account $accountId", OutputInterface::VERBOSITY_VERBOSE, ); } else { $output->writeln( "Updated autoresponder of account $accountId", OutputInterface::VERBOSITY_VERBOSE, ); } } return 0; } }