From 469807a09189a19628558830344f620d9e02265b Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sat, 10 Apr 2021 11:47:24 +0200 Subject: Chore: implement removals from #935 Signed-off-by: Sean Molenaar --- lib/Command/Updater/AllFeeds.php | 74 ------------------------------- lib/Config/LegacyConfig.php | 83 ---------------------------------- lib/Controller/UserApiController.php | 50 --------------------- lib/Migration/MigrateConfig.php | 86 ------------------------------------ lib/Migration/MigrateStatusFlags.php | 67 ---------------------------- 5 files changed, 360 deletions(-) delete mode 100644 lib/Command/Updater/AllFeeds.php delete mode 100644 lib/Config/LegacyConfig.php delete mode 100644 lib/Controller/UserApiController.php delete mode 100644 lib/Migration/MigrateConfig.php delete mode 100644 lib/Migration/MigrateStatusFlags.php (limited to 'lib') diff --git a/lib/Command/Updater/AllFeeds.php b/lib/Command/Updater/AllFeeds.php deleted file mode 100644 index 384508d7d..000000000 --- a/lib/Command/Updater/AllFeeds.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Bernhard Posselt 2016 - */ - -namespace OCA\News\Command\Updater; - -use OCA\News\Service\FeedServiceV2; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; - -/** - * Class AllFeeds - * - * @deprecated use news:feed:list instead - * @package OCA\News\Command\Updater - */ -class AllFeeds extends Command -{ - /** - * @var FeedServiceV2 Feed service - */ - private $feedService; - - /** - * AllFeeds constructor. - * - * @param FeedServiceV2 $feedService - */ - public function __construct(FeedServiceV2 $feedService) - { - parent::__construct(); - $this->feedService = $feedService; - } - - /** - * @return void - */ - protected function configure() - { - $json = '{"feeds": [{"id": 39, "userId": "john"}, // etc ]}'; - - $this->setName('news:updater:all-feeds') - ->setDescription( - 'DEPRECATED: use news:feed:list instead.' . PHP_EOL . - 'Prints a JSON string which contains all feed ' . - 'ids and user ids, e.g.: ' . $json - ); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $feeds = $this->feedService->findAll(); - $result = ['feeds' => []]; - - foreach ($feeds as $feed) { - $result['feeds'][] = [ - 'id' => $feed->getId(), - 'userId' => $feed->getUserId(), - 'folderId' => $feed->getFolderId(), - ]; - } - - $output->write(json_encode($result)); - return 0; - } -} diff --git a/lib/Config/LegacyConfig.php b/lib/Config/LegacyConfig.php deleted file mode 100644 index b0d78f9f1..000000000 --- a/lib/Config/LegacyConfig.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @author Bernhard Posselt - * @copyright 2012 Alessandro Cosentino - * @copyright 2012-2014 Bernhard Posselt - */ - -namespace OCA\News\Config; - -use OCP\Files\Folder; -use Psr\Log\LoggerInterface; - -class LegacyConfig -{ - - private $logger; - private $fileSystem; - - public $autoPurgeMinimumInterval; // seconds, used to define how - // long deleted folders and feeds - // should still be kept for an - // undo actions - public $autoPurgeCount; // number of allowed unread articles per feed - public $maxRedirects; // seconds - public $feedFetcherTimeout; // seconds - public $useCronUpdates; // turn off updates run by the cron - public $maxSize; - public $exploreUrl; - public $updateInterval; - - public function __construct( - ?Folder $fileSystem, - LoggerInterface $logger - ) { - $this->fileSystem = $fileSystem; - $this->logger = $logger; - - $this->autoPurgeMinimumInterval = 60; - $this->autoPurgeCount = 200; - $this->maxRedirects = 10; - $this->maxSize = 100 * 1024 * 1024; // 100Mb - $this->feedFetcherTimeout = 60; - $this->useCronUpdates = true; - $this->exploreUrl = ''; - $this->updateInterval = 3600; - } - - /** - * @param false $createIfNotExists - * - * @return void - */ - public function read($configPath, bool $createIfNotExists = false) - { - if ($this->fileSystem === null) { - return; - } - $content = $this->fileSystem->get($configPath)->getContent(); - $configValues = parse_ini_string($content); - - if ($configValues === false || count($configValues) === 0) { - $this->logger->warning('Configuration invalid. Ignoring values.'); - } else { - foreach ($configValues as $key => $value) { - if (property_exists($this, $key)) { - settype($value, gettype($this->$key)); //@phpstan-ignore-line - $this->$key = $value; //@phpstan-ignore-line - } else { - $this->logger->warning( - 'Configuration value "' . $key . - '" does not exist. Ignored value.' - ); - } - } - } - } -} diff --git a/lib/Controller/UserApiController.php b/lib/Controller/UserApiController.php deleted file mode 100644 index f5721c837..000000000 --- a/lib/Controller/UserApiController.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @author Bernhard Posselt - * @author David Guillot - * @copyright 2012 Alessandro Cosentino - * @copyright 2012-2014 Bernhard Posselt - * @copyright 2018 David Guillot - */ - -namespace OCA\News\Controller; - -use \OCP\IRequest; -use \OCP\IUserSession; - -class UserApiController extends ApiController -{ - public function __construct( - IRequest $request, - ?IUserSession $userSession - ) { - parent::__construct($request, $userSession); - } - - /** - * @NoAdminRequired - * @NoCSRFRequired - * @CORS - * - * @deprecated Should use https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#user-metadata - * and avatar is `https://nc.url/avatar/{userid}/{size}?v={1|2}` - */ - public function index(): array - { - $user = $this->getUser(); - $avatar = null; - - return [ - 'userId' => $user->getUID(), - 'displayName' => $user->getDisplayName(), - 'lastLoginTimestamp' => $user->getLastLogin(), - 'avatar' => $avatar - ]; - } -} diff --git a/lib/Migration/MigrateConfig.php b/lib/Migration/MigrateConfig.php deleted file mode 100644 index 3cf444f50..000000000 --- a/lib/Migration/MigrateConfig.php +++ /dev/null @@ -1,86 +0,0 @@ - 2020 - */ - -namespace OCA\News\Migration; - -use OCA\News\Config\LegacyConfig; -use OCP\IConfig; -use OCP\Migration\IRepairStep; -use OCP\Migration\IOutput; - -class MigrateConfig implements IRepairStep -{ - - /** - * @var LegacyConfig - */ - private $config; - - /** - * @var IConfig - */ - private $iConfig; - - /** - * Array of defaults - * - * @var array - */ - private $defaults; - - /** - * @param LegacyConfig $config - * @param IConfig $iConfig - */ - public function __construct(LegacyConfig $config, IConfig $iConfig) - { - $this->config = $config; - $this->iConfig = $iConfig; - - // copied from Application::default_settings - $this->defaults = [ - 'autoPurgeMinimumInterval' => 60, - 'autoPurgeCount' => 200, - 'maxRedirects' => 10, - 'feedFetcherTimeout' => 60, - 'useCronUpdates' => true, - 'exploreUrl' => '', - 'updateInterval' => 3600, - ]; - } - - public function getName() - { - return 'Migrate config to nextcloud managed config'; - } - - /** - * @return void - */ - public function run(IOutput $output) - { - $version = $this->iConfig->getAppValue('news', 'installed_version', '0.0.0'); - if (version_compare($version, '15.0.6', '>')) { - return; - } - - $app_keys = $this->iConfig->getAppKeys('news'); - foreach ($this->config as $key => $value) { - if (!isset($this->defaults[$key])) { - continue; - } - if (in_array($key, $app_keys)) { - continue; - } - $this->iConfig->setAppValue('news', $key, $value); - } - } -} diff --git a/lib/Migration/MigrateStatusFlags.php b/lib/Migration/MigrateStatusFlags.php deleted file mode 100644 index ac5c8ebe4..000000000 --- a/lib/Migration/MigrateStatusFlags.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Daniel Opitz 2017 - */ - -namespace OCA\News\Migration; - -use OCP\DB\QueryBuilder\IQueryBuilder; -use OCP\IConfig; -use OCP\IDBConnection; -use OCP\Migration\IRepairStep; -use OCP\Migration\IOutput; - -class MigrateStatusFlags implements IRepairStep -{ - - /** - * @var IDBConnection - */ - private $db; - - /** - * @var IConfig - */ - private $config; - - /** - * @param IDBConnection $db - * @param IConfig $config - */ - public function __construct(IDBConnection $db, IConfig $config) - { - $this->db = $db; - $this->config = $config; - } - - public function getName() - { - return 'Migrate binary status into separate boolean fields'; - } - - /** - * @return void - */ - public function run(IOutput $output) - { - $version = $this->config->getAppValue('news', 'installed_version', '0.0.0'); - if (version_compare($version, '11.0.6', '>=')) { - return; - } - - $sql = 'UPDATE `*PREFIX*news_items` ' - . 'SET `unread` = ((`status` & 2) = 2), ' - . '`starred` = ((`status` & 4) = 4)'; - $query = $this->db->prepare($sql); - - if (!$query->execute()) { - throw new \Exception('Could not migrate status'); - } - } -} -- cgit v1.2.3