2018-11-26 12:33:48 +00:00
|
|
|
<?php
|
|
|
|
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;
|
2018-11-26 12:33:48 +00:00
|
|
|
use OCA\Social\Service\ConfigService;
|
2018-12-17 09:12:27 +00:00
|
|
|
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 OCA\Social\Service\MiscService;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
|
|
|
|
class CacheRefresh extends Base {
|
|
|
|
|
|
|
|
|
2018-12-17 09:12:27 +00:00
|
|
|
/** @var AccountService */
|
2019-01-16 13:00:59 +00:00
|
|
|
private $accountService;
|
2018-11-26 12:33:48 +00:00
|
|
|
|
2018-12-17 09:12:27 +00:00
|
|
|
/** @var CacheActorService */
|
|
|
|
private $cacheActorService;
|
2018-11-26 12:33:48 +00:00
|
|
|
|
|
|
|
/** @var DocumentService */
|
|
|
|
private $documentService;
|
|
|
|
|
2019-01-06 12:50:45 +00:00
|
|
|
/** @var HashtagService */
|
|
|
|
private $hashtagService;
|
|
|
|
|
2018-11-26 12:33:48 +00:00
|
|
|
/** @var ConfigService */
|
|
|
|
private $configService;
|
|
|
|
|
|
|
|
/** @var MiscService */
|
|
|
|
private $miscService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CacheUpdate constructor.
|
|
|
|
*
|
2019-01-16 13:00:59 +00:00
|
|
|
* @param AccountService $accountService
|
2018-12-17 09:12:27 +00:00
|
|
|
* @param CacheActorService $cacheActorService
|
2018-11-26 12:33:48 +00:00
|
|
|
* @param DocumentService $documentService
|
2019-01-06 12:50:45 +00:00
|
|
|
* @param HashtagService $hashtagService
|
2018-11-26 12:33:48 +00:00
|
|
|
* @param ConfigService $configService
|
|
|
|
* @param MiscService $miscService
|
|
|
|
*/
|
|
|
|
public function __construct(
|
2019-02-07 17:59:10 +00:00
|
|
|
AccountService $accountService, CacheActorService $cacheActorService,
|
2019-01-06 12:50:45 +00:00
|
|
|
DocumentService $documentService, HashtagService $hashtagService,
|
|
|
|
ConfigService $configService, MiscService $miscService
|
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
|
|
|
$this->configService = $configService;
|
|
|
|
$this->miscService = $miscService;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
protected function configure() {
|
|
|
|
parent::configure();
|
|
|
|
$this->setName('social:cache:refresh')
|
|
|
|
->setDescription('Update the cache');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param InputInterface $input
|
|
|
|
* @param OutputInterface $output
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) {
|
|
|
|
|
2019-01-16 13:00:59 +00:00
|
|
|
$result = $this->accountService->blindKeyRotation();
|
2019-01-02 11:20:11 +00:00
|
|
|
$output->writeLn($result . ' key pairs refreshed');
|
|
|
|
|
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');
|
2018-11-26 12:33:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|