2018-11-26 12:33:48 +00:00
|
|
|
<?php
|
2022-04-15 11:34:01 +00:00
|
|
|
|
2018-11-26 12:33:48 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
/**
|
2024-09-08 13:46:22 +00:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-11-26 12:33:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Social\Command;
|
|
|
|
|
|
|
|
use Exception;
|
|
|
|
use OC\Core\Command\Base;
|
2018-12-17 09:12:27 +00:00
|
|
|
use OCA\Social\Service\AccountService;
|
|
|
|
use OCA\Social\Service\CacheActorService;
|
|
|
|
use OCA\Social\Service\DocumentService;
|
2019-01-06 12:50:45 +00:00
|
|
|
use OCA\Social\Service\HashtagService;
|
2018-11-26 12:33:48 +00:00
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
2023-03-15 15:25:49 +00:00
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
2018-11-26 12:33:48 +00:00
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
class CacheRefresh extends Base {
|
2022-04-15 11:01:18 +00:00
|
|
|
private AccountService $accountService;
|
|
|
|
private CacheActorService $cacheActorService;
|
|
|
|
private DocumentService $documentService;
|
|
|
|
private HashtagService $hashtagService;
|
2018-11-26 12:33:48 +00:00
|
|
|
|
|
|
|
public function __construct(
|
2019-02-07 17:59:10 +00:00
|
|
|
AccountService $accountService, CacheActorService $cacheActorService,
|
2024-10-28 12:53:06 +00:00
|
|
|
DocumentService $documentService, HashtagService $hashtagService,
|
2018-11-26 12:33:48 +00:00
|
|
|
) {
|
|
|
|
parent::__construct();
|
|
|
|
|
2019-01-16 13:00:59 +00:00
|
|
|
$this->accountService = $accountService;
|
2018-12-17 09:12:27 +00:00
|
|
|
$this->cacheActorService = $cacheActorService;
|
2018-11-26 12:33:48 +00:00
|
|
|
$this->documentService = $documentService;
|
2019-01-06 12:50:45 +00:00
|
|
|
$this->hashtagService = $hashtagService;
|
2018-11-26 12:33:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function configure() {
|
|
|
|
parent::configure();
|
|
|
|
$this->setName('social:cache:refresh')
|
2024-10-28 12:53:06 +00:00
|
|
|
->setDescription('Update the cache')
|
2023-03-15 15:25:49 +00:00
|
|
|
->addOption('force', 'f', InputOption::VALUE_NONE, 'enforce update of cached account');
|
2018-11-26 12:33:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
2022-11-20 12:31:31 +00:00
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
2023-05-25 20:45:28 +00:00
|
|
|
// $result = $this->accountService->blindKeyRotation();
|
|
|
|
// $output->writeLn($result . ' key pairs refreshed');
|
2023-01-05 09:58:13 +00:00
|
|
|
|
|
|
|
$result = $this->accountService->manageDeletedActors();
|
|
|
|
$output->writeLn($result . ' local accounts deleted');
|
2019-01-02 11:20:11 +00:00
|
|
|
|
2019-01-16 13:00:59 +00:00
|
|
|
$result = $this->accountService->manageCacheLocalActors();
|
2018-11-26 12:33:48 +00:00
|
|
|
$output->writeLn($result . ' local accounts regenerated');
|
|
|
|
|
2018-12-17 09:12:27 +00:00
|
|
|
$result = $this->cacheActorService->missingCacheRemoteActors();
|
2018-11-29 14:31:08 +00:00
|
|
|
$output->writeLn($result . ' remote accounts created');
|
|
|
|
|
2023-03-15 15:25:49 +00:00
|
|
|
$result = $this->cacheActorService->manageCacheRemoteActors($input->getOption('force'));
|
2018-11-26 12:33:48 +00:00
|
|
|
$output->writeLn($result . ' remote accounts updated');
|
|
|
|
|
2023-04-11 09:27:54 +00:00
|
|
|
$result = $this->cacheActorService->manageDetailsRemoteActors($input->getOption('force'));
|
|
|
|
$output->writeLn($result . ' remote accounts details updated');
|
|
|
|
|
2018-11-26 12:33:48 +00:00
|
|
|
$result = $this->documentService->manageCacheDocuments();
|
|
|
|
$output->writeLn($result . ' documents cached');
|
2019-01-06 12:50:45 +00:00
|
|
|
|
|
|
|
$result = $this->hashtagService->manageHashtags();
|
|
|
|
$output->writeLn($result . ' hashtags updated');
|
2022-11-20 12:31:31 +00:00
|
|
|
|
|
|
|
return 0;
|
2018-11-26 12:33:48 +00:00
|
|
|
}
|
|
|
|
}
|