summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2021-04-10 11:47:24 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2021-06-01 11:23:04 +0200
commit469807a09189a19628558830344f620d9e02265b (patch)
tree202e3d56afdd3966d9e7c35f6da7c3ca685120d1
parentf0008643b54498d747eaa21ec4627c16942da443 (diff)
Chore: implement removals from #935
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
-rw-r--r--AUTHORS.md16
-rw-r--r--CHANGELOG.md4
-rw-r--r--appinfo/info.xml1
-rw-r--r--lib/Command/Updater/AllFeeds.php74
-rw-r--r--lib/Config/LegacyConfig.php83
-rw-r--r--lib/Controller/UserApiController.php50
-rw-r--r--lib/Migration/MigrateConfig.php86
-rw-r--r--lib/Migration/MigrateStatusFlags.php67
-rw-r--r--tests/Unit/Controller/UserApiControllerTest.php150
9 files changed, 18 insertions, 513 deletions
diff --git a/AUTHORS.md b/AUTHORS.md
index e6d7dca80..afeda70f2 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -2,23 +2,28 @@
* [Bernhard Posselt](mailto:dev@bernhard-posselt.com)
* [Alessandro Cosentino](mailto:cosenal@gmail.com)
* [Benjamin Brahmer](mailto:info@b-brahmer.de)
+* [Marco Nassabain](mailto:marco.nassabain@hotmail.com)
* [Robin Appelman](mailto:icewind@owncloud.com)
* [Sean Molenaar](mailto:sean@seanmolenaar.eu)
* [Gregor Tätzner](mailto:gregor@freenet.de)
* [Sean Molenaar](mailto:SMillerDev@users.noreply.github.com)
* [Morris Jobke](mailto:hey@morrisjobke.de)
* [anoy](mailto:anoymouserver+github@mailbox.org)
+* [Jimmy Huynh](mailto:jimmy.huynh@etu.unistra.fr)
+* [Aurélien](mailto:dav.aurelien@gmail.com)
* [Jan-Christoph Borchardt](mailto:hey@jancborchardt.net)
+* [Paul Tirk](mailto:paultirk@paultirk.com)
* [Daniel Schaal](mailto:daniel@schaal.email)
* [Davide Saurino](mailto:davide.saurino@alcacoop.it)
* [raghunayyar](mailto:me@iraghu.com)
+* [WENDLING NICOLAS](mailto:nicolas.wendling2@etu.unistra.fr)
* [bastei](mailto:bastei@users.noreply.github.com)
* [Bernhard Posselt](mailto:bep@foryouandyourcustomers.com)
* [Thomas Müller](mailto:thomas.mueller@tmit.eu)
* [Hoàng Đức Hiếu](mailto:hdhoang@zahe.me)
+* [Marco Nassabain](mailto:marco.nassabain@etu.unistra.fr)
* [rakekniven](mailto:mark.ziegler@rakekniven.de)
* [Daniel Opitz](mailto:git@copynpaste.de)
-* [Marco Nassabain](mailto:marco.nassabain@hotmail.com)
* [Sean Molenaar](mailto:sean@m2mobi.com)
* [David-Development](mailto:david-dev@live.de)
* [IBBoard](mailto:dev@ibboard.co.uk)
@@ -26,7 +31,7 @@
* [Lukas Reschke](mailto:lukas@owncloud.com)
* [Bart Visscher](mailto:bartv@thisnet.nl)
* [Christian Elmer](mailto:christian@keinkurt.de)
-* [Jimmy Huynh](mailto:jimmy.huynh@etu.unistra.fr)
+* [Nicolas Wendling](mailto:nicolas.wendling1011@gmail.com)
* [Thomas Tanghus](mailto:thomas@tanghus.net)
* [Volkan Gezer](mailto:volkangezer@gmail.com)
* [Xéfir Destiny](mailto:xefir@crystalyx.net)
@@ -39,11 +44,13 @@
* [Brice Maron](mailto:brice@bmaron.net)
* [Christoph Stenglein](mailto:christoph@christophstenglein.com)
* [Daniel Kesselberg](mailto:mail@danielkesselberg.de)
+* [ELHADDAD Hamza](mailto:elhaddadhamza49@gmail.com)
* [Jakob Sack](mailto:mail@jakobsack.de)
* [Qingping Hou](mailto:dave2008713@gmail.com)
* [Roman](mailto:reverse@jamm.me)
* [b_b](mailto:bruno@eliaz.fr)
* [heyarne](mailto:arne@schlueter.is)
+* [marco.nassabain@etu.unistra.fr](mailto:marco.nassabain@hotmail.com)
* [Andreas Fischer](mailto:bantu@owncloud.com)
* [David Guillot](mailto:david@guillot.me)
* [Gioele Falcetti](mailto:thegio.f@gmail.com)
@@ -73,6 +80,8 @@
* [Andrea Boero](mailto:mail@tsumi.it)
* [Andreas Demmelbauer](mailto:git@notice.at)
* [Arthur Schiwon](mailto:blizzz@arthur-schiwon.de)
+* [Aurelien DAVID](mailto:aurelien.david@etu.unistra.fr)
+* [Aurelien DAVID](mailto:dav.aurelien@gmail.com)
* [Benedikt Geißler](mailto:benedikt@g5r.eu)
* [Bernhard Posselt](mailto:bernhard@desktop.localdomain)
* [Candid Dauth](mailto:cdauth@cdauth.eu)
@@ -132,6 +141,7 @@
* [Tilo Spannagel](mailto:development@tilosp.de)
* [Timo Schmidt](mailto:timo@xinterchange.net)
* [Tucker McKnight](mailto:tucker.mcknight@gmail.com)
+* [WENDLING NICOLAS](mailto:nicolas.wendling1011@gmail.com)
* [Welling Guzmán](mailto:WellingGuzman@users.noreply.github.com)
* [Xaver Maierhofer](mailto:xaver.maierhofer@xwissen.info)
* [Xemle](mailto:xemle@phtagr.org)
@@ -141,6 +151,7 @@
* [b_b](mailto:brunobergot@gmail.com)
* [bjoerns1983](mailto:bjoern@sengotta.net)
* [blackcrack](mailto:blackcrack@blackysgate.de)
+* [cherguimalih](mailto:ilyes.chergui-malih@etu.unistra.fr)
* [comradekingu](mailto:epost@anotheragency.no)
* [derritter88](mailto:derritter88@users.noreply.github.com)
* [e-alfred](mailto:e-alfred@users.noreply.github.com)
@@ -149,6 +160,7 @@
* [kesselb](mailto:mail@danielkesselberg.de)
* [kondou](mailto:kondou@ts.unde.re)
* [markusj](mailto:markusj@users.noreply.github.com)
+* [mnassabain](mailto:34754819+mnassabain@users.noreply.github.com)
* [nexus-uw](mailto:you@example.com)
* [repat](mailto:repat@repat.de)
* [ritchiewilson](mailto:rawilson52@gmail.com)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cecabbd45..fb90606f1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,10 @@ The format is almost based on [Keep a Changelog](https://keepachangelog.com/en/1
# Unreleased
## [16.x.x]
### Changed
+- Remove deprecated API endpoints and occ comand (#935)
+ - /api/v1-2/user
+ - /api/v1-2/user/avatar
+ - ./occ news:updater:all-feeds
### Fixed
- allow calling `/items?getRead=false` without a feed/folder (#1380 #1356)
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 8c1970c17..53eb1afce 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -68,7 +68,6 @@ Report a [feed issue](https://github.com/nextcloud/news/discussions/new)
<commands>
<command>OCA\News\Command\ExploreGenerator</command>
<command>OCA\News\Command\ShowFeed</command>
- <command>OCA\News\Command\Updater\AllFeeds</command>
<command>OCA\News\Command\Updater\UpdateFeed</command>
<command>OCA\News\Command\Updater\BeforeUpdate</command>
<command>OCA\News\Command\Updater\AfterUpdate</command>
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 @@
-<?php
-/**
- * Nextcloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @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 @@
-<?php
-/**
- * Nextcloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Alessandro Cosentino <cosenal@gmail.com>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @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 @@
-<?php
-/**
- * Nextcloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Alessandro Cosentino <cosenal@gmail.com>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @author David Guillot <david@guillot.me>
- * @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 @@
-<?php
-/**
- * Nextcloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Sean Molenaar
- * @copyright Sean Molenaar <sean@seanmolenaar.eu> 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 @@
-<?php
-/**
- * Nextcloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Daniel Opitz <dev@copynpaste.de>
- * @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');
- }
- }
-}
diff --git a/tests/Unit/Controller/UserApiControllerTest.php b/tests/Unit/Controller/UserApiControllerTest.php
deleted file mode 100644
index 45a59ce4b..000000000
--- a/tests/Unit/Controller/UserApiControllerTest.php
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php
-/**
- * Nextcloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Alessandro Cosentino <cosenal@gmail.com>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright 2012 Alessandro Cosentino
- * @copyright 2012-2014 Bernhard Posselt
- */
-
-namespace OCA\News\Tests\Unit\Controller;
-
-use OCA\News\Controller\UserApiController;
-use OCP\Files\File;
-use OCP\Files\IRootFolder;
-use OCP\IRequest;
-use OCP\IUser;
-use OCP\IUserSession;
-
-use PHPUnit\Framework\TestCase;
-
-class UserApiControllerTest extends TestCase
-{
-
- private $request;
- private $appName;
- private $rootFolder;
- private $userSession;
- private $controller;
- private $user;
- private $file;
-
- protected function setUp(): void
- {
- $this->appName = 'news';
- $this->request = $this->getMockBuilder(IRequest::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->rootFolder = $this->getMockBuilder(IRootFolder::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->file = $this->getMockBuilder(File::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->userSession = $this->getMockBuilder(IUserSession::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->user = $this->getMockBuilder(IUser::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->controller = new UserApiController(
- $this->request,
- $this->userSession,
- $this->rootFolder
- );
-
-
- }
-
- private function expectUser($uid, $displayName, $lastLogin)
- {
- $this->userSession->expects($this->any())
- ->method('getUser')
- ->will($this->returnValue($this->user));
- $this->user->expects($this->any())
- ->method('getUID')
- ->will($this->returnValue($uid));
- $this->user->expects($this->any())
- ->method('getLastLogin')
- ->will($this->returnValue($lastLogin));
- $this->user->expects($this->any())
- ->method('getDisplayName')
- ->will($this->returnValue($displayName));
- }
-
- private function expectImg($isJpg, $isPng, $user, $exists, $data)
- {
- $jpg = '/' . $user . '/' . 'avatar.jpg';
- $png = '/' . $user . '/' . 'avatar.png';
-
- $this->rootFolder->expects($this->any())
- ->method('nodeExists')
- ->will(
- $this->returnValueMap(
- [
- [$jpg, $isJpg],
- [$png, $isPng]
- ]
- )
- );
- $this->rootFolder->expects($this->any())
- ->method('get')
- ->will($this->returnValue($this->file));
- $this->file->expects($this->any())
- ->method('getContent')
- ->will($this->returnValue($data));
- }
-
- public function testGetJpeg()
- {
- $this->expectUser('john', 'John', 123);
- $this->expectImg(true, false, 'john', true, 'hi');
-
- $result = $this->controller->index();
- $expected = [
- 'userId' => 'john',
- 'displayName' => 'John',
- 'lastLoginTimestamp' => 123,
- 'avatar' => null
- ];
-
- $this->assertEquals($expected, $result);
- }
-
- public function testGetPng()
- {
- $this->expectUser('john', 'John', 123);
- $this->expectImg(false, true, 'john', false, 'hi');
-
- $result = $this->controller->index();
- $expected = [
- 'userId' => 'john',
- 'displayName' => 'John',
- 'lastLoginTimestamp' => 123,
- 'avatar' => null
- ];
-
- $this->assertEquals($expected, $result);
- }
-
- public function testNoAvatar()
- {
- $this->expectUser('john', 'John', 123);
- $this->expectImg(false, false, 'john', false, 'hi');
-
- $result = $this->controller->index();
- $expected = [
- 'userId' => 'john',
- 'displayName' => 'John',
- 'lastLoginTimestamp' => 123,
- 'avatar' => null
- ];
-
- $this->assertEquals($expected, $result);
- }
-
-}