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);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Nextcloud - Social Support
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later. See the COPYING file.
|
|
|
|
*
|
|
|
|
* @author Maxence Lange <maxence@artificial-owl.com>
|
|
|
|
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
|
|
|
|
* @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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
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,
|
2022-04-15 11:01:18 +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')
|
|
|
|
->setDescription('Update the cache');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
2022-11-20 12:31:31 +00:00
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
2023-01-05 09:58:13 +00:00
|
|
|
// $result = $this->accountService->blindKeyRotation();
|
|
|
|
// $output->writeLn($result . ' key pairs refreshed');
|
|
|
|
|
|
|
|
$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');
|
|
|
|
|
2018-12-17 09:12:27 +00:00
|
|
|
$result = $this->cacheActorService->manageCacheRemoteActors();
|
2018-11-26 12:33:48 +00:00
|
|
|
$output->writeLn($result . ' remote accounts updated');
|
|
|
|
|
|
|
|
$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
|
|
|
}
|
|
|
|
}
|