Chore: implement removals from #935

Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
This commit is contained in:
Sean Molenaar 2021-04-10 11:47:24 +02:00 committed by Benjamin Brahmer
parent f0008643b5
commit 469807a091
9 changed files with 18 additions and 513 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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>

View File

@ -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;
}
}

View File

@ -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.'
);
}
}
}
}
}

View File

@ -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
];
}
}

View File

@ -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);
}
}
}

View File

@ -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');
}
}
}

View File

@ -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);
}
}