diff options
26 files changed, 1016 insertions, 1234 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 815059c41..a76ccf06f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file. ## Unreleased +## Changed +- Remove outdated folder DB code + ## 15.1.0 ### Changed diff --git a/composer.lock b/composer.lock index d71dc2448..67a3294a9 100644 --- a/composer.lock +++ b/composer.lock @@ -57,6 +57,10 @@ "html", "readability" ], + "support": { + "issues": "https://github.com/andreskrey/readability.php/issues", + "source": "https://github.com/andreskrey/readability.php/tree/v2.1.0" + }, "time": "2019-07-22T21:42:25+00:00" }, { @@ -110,6 +114,11 @@ "finder", "icon" ], + "support": { + "issues": "https://github.com/ArthurHoaro/favicon/issues", + "source": "https://github.com/ArthurHoaro/favicon/tree/v1.3.1", + "sources": "https://github.com/ArthurHoaro/favicon" + }, "time": "2020-10-14T09:32:44+00:00" }, { @@ -173,6 +182,10 @@ "news", "rss" ], + "support": { + "issues": "https://github.com/alexdebril/feed-io/issues", + "source": "https://github.com/alexdebril/feed-io/tree/v4.7.10" + }, "funding": [ { "url": "https://github.com/alexdebril", @@ -229,6 +242,10 @@ "keywords": [ "html" ], + "support": { + "issues": "https://github.com/ezyang/htmlpurifier/issues", + "source": "https://github.com/ezyang/htmlpurifier/tree/master" + }, "time": "2020-06-29T00:56:53+00:00" }, { @@ -293,6 +310,10 @@ "uri", "url" ], + "support": { + "issues": "https://pear.php.net/bugs/search.php?cmd=display&package_name[]=Net_URL2", + "source": "https://github.com/pear/Net_URL2" + }, "time": "2017-08-25T06:16:11+00:00" }, { @@ -340,6 +361,9 @@ "psr", "psr-3" ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.3" + }, "time": "2020-03-23T09:12:05+00:00" }, { @@ -390,6 +414,10 @@ "path", "system" ], + "support": { + "issues": "https://github.com/Riimu/Kit-PathJoin/issues", + "source": "https://github.com/Riimu/Kit-PathJoin/tree/master" + }, "time": "2017-07-09T14:41:04+00:00" }, { @@ -441,6 +469,11 @@ "phpcs", "standards" ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, "time": "2020-10-23T02:01:07+00:00" } ], @@ -494,6 +527,10 @@ "constructor", "instantiate" ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + }, "funding": [ { "url": "https://www.doctrine-project.org/sponsorship.html", @@ -512,16 +549,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.10.1", + "version": "1.10.2", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5" + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", - "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", "shasum": "" }, "require": { @@ -556,13 +593,17 @@ "object", "object graph" ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + }, "funding": [ { "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", "type": "tidelift" } ], - "time": "2020-06-29T13:22:24+00:00" + "time": "2020-11-13T09:40:50+00:00" }, { "name": "phar-io/manifest", @@ -617,6 +658,10 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/master" + }, "time": "2018-07-08T19:23:20+00:00" }, { @@ -664,6 +709,10 @@ } ], "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/master" + }, "time": "2018-07-08T19:19:57+00:00" }, { @@ -713,6 +762,10 @@ "reflection", "static analysis" ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, "time": "2020-06-27T09:03:43+00:00" }, { @@ -765,6 +818,10 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + }, "time": "2020-09-03T19:13:55+00:00" }, { @@ -810,6 +867,10 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0" + }, "time": "2020-09-17T18:55:26+00:00" }, { @@ -873,6 +934,10 @@ "spy", "stub" ], + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/1.12.1" + }, "time": "2020-09-29T09:10:42+00:00" }, { @@ -915,6 +980,10 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/0.12.55" + }, "funding": [ { "url": "https://github.com/ondrejmirtes", @@ -993,6 +1062,10 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/8.0.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1049,6 +1122,10 @@ "filesystem", "iterator" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1108,6 +1185,10 @@ "keywords": [ "process" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1163,6 +1244,10 @@ "keywords": [ "template" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1218,6 +1303,10 @@ "keywords": [ "timer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1273,6 +1362,10 @@ "keywords": [ "tokenizer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", + "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1368,6 +1461,10 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.2.6" + }, "funding": [ { "url": "https://phpunit.de/donate.html", @@ -1424,6 +1521,10 @@ ], "description": "Collection of value objects that represent the PHP code units", "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1475,6 +1576,10 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1545,6 +1650,10 @@ "compare", "equality" ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1607,6 +1716,10 @@ "unidiff", "unified diff" ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1666,6 +1779,10 @@ "environment", "hhvm" ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1739,6 +1856,10 @@ "export", "exporter" ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1799,6 +1920,10 @@ "keywords": [ "global state" ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/master" + }, "time": "2020-02-07T06:11:37+00:00" }, { @@ -1846,6 +1971,10 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1897,6 +2026,10 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1956,6 +2089,10 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -2007,6 +2144,10 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -2059,6 +2200,10 @@ ], "description": "Collection of value objects that represent the types of the PHP type system", "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/2.3.1" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -2108,6 +2253,10 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -2176,6 +2325,9 @@ "polyfill", "portable" ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.20.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -2230,6 +2382,10 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/master" + }, "funding": [ { "url": "https://github.com/theseer", @@ -2285,6 +2441,10 @@ "check", "validate" ], + "support": { + "issues": "https://github.com/webmozart/assert/issues", + "source": "https://github.com/webmozart/assert/tree/master" + }, "time": "2020-07-08T17:02:28+00:00" } ], @@ -2302,5 +2462,5 @@ "ext-curl": "*" }, "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } diff --git a/lib/Controller/FeedController.php b/lib/Controller/FeedController.php index 5e2ba8a96..76f777a12 100644 --- a/lib/Controller/FeedController.php +++ b/lib/Controller/FeedController.php @@ -15,6 +15,7 @@ namespace OCA\News\Controller; use OCA\News\Service\Exceptions\ServiceConflictException; use OCA\News\Service\Exceptions\ServiceNotFoundException; +use OCA\News\Service\FolderServiceV2; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\IConfig; @@ -23,8 +24,9 @@ use OCP\AppFramework\Http; use OCA\News\Service\ItemService; use OCA\News\Service\FeedService; -use OCA\News\Service\FolderService; use OCA\News\Db\FeedType; +use OCP\IUser; +use OCP\IUserSession; class FeedController extends Controller { @@ -33,27 +35,29 @@ class FeedController extends Controller //TODO: Remove private $feedService; //TODO: Remove - private $folderService; - //TODO: Remove private $itemService; + /** + * @var FolderServiceV2 + */ + private $folderService; private $userId; private $settings; public function __construct( string $appName, IRequest $request, - FolderService $folderService, + FolderServiceV2 $folderService, FeedService $feedService, ItemService $itemService, IConfig $settings, - string $UserId + IUser $user ) { parent::__construct($appName, $request); - $this->feedService = $feedService; $this->folderService = $folderService; - $this->itemService = $itemService; - $this->userId = $UserId; - $this->settings = $settings; + $this->feedService = $feedService; + $this->itemService = $itemService; + $this->settings = $settings; + $this->userId = $user->getUID(); } diff --git a/lib/Controller/FolderController.php b/lib/Controller/FolderController.php index e67299c6d..662d45029 100644 --- a/lib/Controller/FolderController.php +++ b/lib/Controller/FolderController.php @@ -19,18 +19,20 @@ use \OCP\IRequest; use \OCP\AppFramework\Controller; use \OCP\AppFramework\Http; -use \OCA\News\Service\FolderService; +use \OCA\News\Service\FolderServiceV2; use \OCA\News\Service\FeedService; use \OCA\News\Service\ItemService; use \OCA\News\Service\Exceptions\ServiceNotFoundException; use \OCA\News\Service\Exceptions\ServiceConflictException; -use \OCA\News\Service\Exceptions\ServiceValidationException; +use OCP\IUser; class FolderController extends Controller { - use JSONHttpErrorTrait; + use JSONHttpErrorTrait, ApiPayloadTrait; - //TODO: Remove + /** + * @var FolderServiceV2 + */ private $folderService; //TODO: Remove private $feedService; @@ -41,16 +43,16 @@ class FolderController extends Controller public function __construct( string $appName, IRequest $request, - FolderService $folderService, + FolderServiceV2 $folderService, FeedService $feedService, ItemService $itemService, - $UserId + IUser $user ) { parent::__construct($appName, $request); $this->folderService = $folderService; $this->feedService = $feedService; $this->itemService = $itemService; - $this->userId = $UserId; + $this->userId = $user->getUID(); } @@ -60,7 +62,7 @@ class FolderController extends Controller public function index() { $folders = $this->folderService->findAllForUser($this->userId); - return ['folders' => $folders]; + return ['folders' => $this->serialize($folders)]; } @@ -77,7 +79,7 @@ class FolderController extends Controller $folderId = $folderId === 0 ? null : $folderId; try { - $this->folderService->open($folderId, $open, $this->userId); + $this->folderService->open($this->userId, $folderId, $open); } catch (ServiceException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } @@ -89,24 +91,17 @@ class FolderController extends Controller /** * @NoAdminRequired * - * @param string $folderName + * @param string $folderName + * @param int|null $parent * * @return array|JSONResponse */ - public function create(string $folderName) + public function create(string $folderName, ?int $parent = null) { - try { - // we need to purge deleted folders if a folder is created to - // prevent already exists exceptions - $this->folderService->purgeDeleted($this->userId, false); - $folder = $this->folderService->create($folderName, $this->userId); + $this->folderService->purgeDeleted(); + $folder = $this->folderService->create($this->userId, $folderName, $parent); - return ['folders' => [$folder]]; - } catch (ServiceConflictException $ex) { - return $this->error($ex, Http::STATUS_CONFLICT); - } catch (ServiceValidationException $ex) { - return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); - } + return ['folders' => $this->serialize($folder)]; } @@ -123,9 +118,11 @@ class FolderController extends Controller return new JSONResponse([], Http::STATUS_BAD_REQUEST); } try { - $this->folderService->markDeleted($folderId, $this->userId); + $this->folderService->markDelete($this->userId, $folderId, true); } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); + } catch (ServiceConflictException $ex) { + return $this->error($ex, Http::STATUS_CONFLICT); } return []; @@ -146,17 +143,11 @@ class FolderController extends Controller return new JSONResponse([], Http::STATUS_BAD_REQUEST); } try { - $folder = $this->folderService->rename( - $folderId, - $folderName, - $this->userId - ); + $folder = $this->folderService->rename($this->userId, $folderId, $folderName); - return ['folders' => [$folder]]; + return ['folders' => $this->serialize($folder)]; } catch (ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); - } catch (ServiceValidationException $ex) { - return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } @@ -179,8 +170,8 @@ class FolderController extends Controller $highestItemId, $this->userId ); - - return ['feeds' => $this->feedService->findAllForUser($this->userId)]; + $feeds = $this->feedService->findAllForUser($this->userId); + |