diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | composer.lock | 157 | ||||
-rw-r--r-- | docs/externalapi/Legacy.md | 60 | ||||
-rw-r--r-- | lib/Controller/AdminController.php | 20 | ||||
-rw-r--r-- | lib/Controller/ApiController.php | 2 | ||||
-rw-r--r-- | lib/Controller/FeedApiController.php | 66 | ||||
-rw-r--r-- | lib/Controller/FeedController.php | 3 | ||||
-rw-r--r-- | lib/Controller/FolderApiController.php | 26 | ||||
-rw-r--r-- | lib/Controller/FolderController.php | 3 | ||||
-rw-r--r-- | lib/Controller/ItemApiController.php | 75 | ||||
-rw-r--r-- | lib/Service/FeedServiceV2.php | 4 | ||||
-rw-r--r-- | lib/Service/FolderServiceV2.php | 8 | ||||
-rw-r--r-- | tests/Unit/Controller/FeedApiControllerTest.php | 119 | ||||
-rw-r--r-- | tests/Unit/Controller/FolderApiControllerTest.php | 26 | ||||
-rw-r--r-- | tests/Unit/Controller/ItemApiControllerTest.php | 85 |
15 files changed, 420 insertions, 235 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 96f2afb57..ce1a8b881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - Upload codecoverage to codecov.io - Use foreign keys in db - Fix delete api not working +- Move controllers to use V2 services ## 15.0.6 diff --git a/composer.lock b/composer.lock index 7c9837f5e..b480d54b7 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" }, { @@ -504,6 +532,10 @@ "constructor", "instantiate" ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.3.x" + }, "funding": [ { "url": "https://www.doctrine-project.org/sponsorship.html", @@ -566,6 +598,10 @@ "object", "object graph" ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.x" + }, "funding": [ { "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", @@ -627,6 +663,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" }, { @@ -674,6 +714,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" }, { @@ -723,6 +767,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" }, { @@ -775,6 +823,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" }, { @@ -820,6 +872,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" }, { @@ -883,6 +939,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" }, { @@ -925,6 +985,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.53" + }, "funding": [ { "url": "https://github.com/ondrejmirtes", @@ -1003,6 +1067,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", @@ -1059,6 +1127,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", @@ -1118,6 +1190,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", @@ -1173,6 +1249,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", @@ -1228,6 +1308,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", @@ -1283,6 +1367,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", @@ -1378,6 +1466,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", @@ -1434,6 +1526,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", @@ -1485,6 +1581,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", @@ -1555,6 +1655,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", @@ -1617,6 +1721,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", @@ -1676,6 +1784,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", @@ -1749,6 +1861,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", @@ -1809,6 +1925,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" }, { @@ -1856,6 +1976,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", @@ -1907,6 +2031,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", @@ -1966,6 +2094,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", @@ -2017,6 +2149,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", @@ -2069,6 +2205,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", @@ -2118,6 +2258,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", @@ -2186,6 +2330,9 @@ "polyfill", "portable" ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.20.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -2240,6 +2387,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", @@ -2295,6 +2446,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" } ], @@ -2312,5 +2467,5 @@ "ext-curl": "*" }, "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } diff --git a/docs/externalapi/Legacy.md b/docs/externalapi/Legacy.md index f8ec4fb61..e5df7a8e1 100644 --- a/docs/externalapi/Legacy.md +++ b/docs/externalapi/Legacy.md @@ -132,7 +132,7 @@ angular.module('YourApp', []) In general the input parameters can be in the URL or request body, the App Framework doesnt differentiate between them. So JSON in the request body like: -```js +```json { "id": 3 } @@ -159,7 +159,7 @@ The output is JSON. * **Route**: /folders * **Parameters**: none * **Returns**: -```js +```json { "folders": [ { @@ -177,7 +177,7 @@ Creates a new folder and returns a new folder object * **Method**: POST * **Route**: /folders * **Parameters**: -```js +```json { "name": "folder name" } @@ -186,7 +186,7 @@ Creates a new folder and returns a new folder object * **HTTP 409**: If the folder exists already * **HTTP 422**: If the folder name is invalid (for instance empty) * **Returns**: -```js +```json { "folders": [ { @@ -215,7 +215,7 @@ Only the name can be updated * **Method**: PUT * **Route**: /folders/{folderId} * **Parameters**: -```js +```json { "name": "folder name" } @@ -232,7 +232,7 @@ Only the name can be updated * **Method**: PUT * **Route**: /folders/{folderId}/read * **Parameters**: -```js +```json { // mark all items read lower than equal that id // this is mean to prevent marking items as read which the client/user does not yet know of @@ -259,7 +259,7 @@ The following attributes are **not sanitized** meaning: including them in your w * **Route**: /feeds * **Parameters**: none * **Returns**: -```js +```json { "feeds": [ { @@ -294,7 +294,7 @@ Creates a new feed and returns the feed * **Method**: POST * **Route**: /feeds * **Parameters**: -```js +```json { "url": "http:\/\/www.cyanogenmod.org\/wp-content\/themes\/cyanogenmod\/images\/favicon.ico", "folderId": 81 // id of the parent folder, 0 for root @@ -304,7 +304,7 @@ Creates a new feed and returns the feed * **HTTP 409**: If the feed exists already * **HTTP 422**: If the feed cant be read (most likely contains errors) * **Returns**: -```js +```json { "feeds": [ { @@ -341,7 +341,7 @@ Deletes a feed with the id feedId and all of its items * **Method**: PUT * **Route**: /feeds/{feedId}/move * **Parameters**: -```js +```json { "folderId": 0 // id of the parent folder, 0 for root } @@ -356,7 +356,7 @@ Deletes a feed with the id feedId and all of its items * **Method**: PUT * **Route**: /feeds/{feedId}/rename * **Parameters**: -```js +```json { "feedTitle": 'New Title' } @@ -371,7 +371,7 @@ Deletes a feed with the id feedId and all of its items * **Method**: PUT * **Route**: /feeds/{feedId}/read * **Parameters**: -```js +```json { // mark all items read lower than equal that id // this is mean to prevent marking items as read which the client/user does not yet know of @@ -402,7 +402,7 @@ The following attributes are **not sanitized** meaning: including them in your w * **Method**: GET * **Route**: /items * **Parameters**: -```js +```json { "batchSize": 10, // the number of items that should be returned, defaults to -1, new in 5.2.3: -1 returns all items "offset": 30, // only return older (lower than equal that id) items than the one with id 30 @@ -413,7 +413,7 @@ The following attributes are **not sanitized** meaning: including them in your w } ``` * **Returns**: -```js +```json { "items": [ { @@ -446,7 +446,7 @@ Autopaging would work like this: * Get the **first 20** items from a feed with **id 12** **GET /items**: -```js +```json { "batchSize": 20, "offset": 0, @@ -460,7 +460,7 @@ The item with the lowest item id is 43. * Get the next **20** items: **GET /items**: -```js +```json { "batchSize": 20, "offset": 43, @@ -478,7 +478,7 @@ This is used to stay up to date. * **Method**: GET * **Route**: /items/updated * **Parameters**: -```js +```json { "lastModified": 123231, // returns only items with a lastModified timestamp >= than this one // this may also return already existing items whose read or starred status @@ -488,7 +488,7 @@ This is used to stay up to date. } ``` * **Returns**: -```js +```json { "items": [ { @@ -526,7 +526,7 @@ This is used to stay up to date. * **Method**: PUT * **Route**: /items/read/multiple * **Parameters**: -```js +```json { "items": [2, 3] // ids of the items } @@ -547,7 +547,7 @@ This is used to stay up to date. * **Method**: PUT * **Route**: /items/unread/multiple * **Parameters**: -```js +```json { "items": [2, 3] // ids of the items } @@ -568,7 +568,7 @@ This is used to stay up to date. * **Method**: PUT * **Route**: /items/star/multiple * **Parameters**: -```js +```json { "items": [ { @@ -594,7 +594,7 @@ This is used to stay up to date. * **Method**: PUT * **Route**: /items/unstar/multiple * **Parameters**: -```js +```json { "items": [ { @@ -612,7 +612,7 @@ This is used to stay up to date. * **Method**: PUT * **Route**: /items/read * **Parameters**: -```js +```json { // mark all items read lower than equal that id // this is mean to prevent marking items as read which the client/user does not yet know of @@ -657,7 +657,7 @@ This is used to clean up the database. It deletes folders and feeds that are mar * **Route**: /feeds/all * **Parameters**: none * **Returns**: -```js +```json { "feeds": [ { @@ -680,7 +680,7 @@ This is used to clean up the database. It deletes folders and feeds that are mar * **Method**: GET * **Route**: /feeds/update * **Parameters**: -```js +```json { "userId": "john", "feedId": 3 @@ -716,7 +716,7 @@ This is used to clean up the database. It removes old read articles which are no * **Route**: /version * **Parameters**: none * **Returns**: -```js +```json { "version": "5.2.3" } @@ -733,7 +733,7 @@ This API can be used to display warnings and errors in your client if the web ap * **Route**: /status * **Parameters**: none * **Returns**: -```js +```json { "version": "5.2.4", "warnings": { @@ -756,7 +756,9 @@ If **incorrectDbCharset** is true you should display a warning that database cha # User -This API can be used to retrieve metadata about the current user +This API can be used to retrieve metadata about the current user. + +DEPRECATED: This API is deprecated, use the Nextcloud APIs instead. ## Get the status @@ -765,7 +767,7 @@ This API can be used to retrieve metadata about the current user * **Route**: /user * **Parameters**: none * **Returns**: -```js +```json { "userId": "john", "displayName": "John Doe", diff --git a/lib/Controller/AdminController.php b/lib/Controller/AdminController.php index e3551a2a1..059a0c4a7 100644 --- a/lib/Controller/AdminController.php +++ b/lib/Controller/AdminController.php @@ -20,8 +20,6 @@ use OCP\IConfig; use OCP\IRequest; use OCP\AppFramework\Controller; -use OCA\News\Service\ItemService; - /** * Class AdminController * @@ -36,27 +34,17 @@ class AdminController extends Controller private $config; /** - * @var ItemService - */ - private $itemService; - - /** * AdminController constructor. * * @param string $appName The name of the app * @param IRequest $request The request * @param IConfig $config Config for nextcloud - * @param ItemService $itemService Service for items */ - public function __construct( - string $appName, - IRequest $request, - IConfig $config, - ItemService $itemService - ) { + public function __construct(string $appName, IRequest $request, IConfig $config) + { parent::__construct($appName, $request); - $this->config = $config; - $this->itemService = $itemService; + + $this->config = $config; } /** diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index 544b2c23b..de7a0919c 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -41,7 +41,7 @@ class ApiController extends BaseApiController * @param IRequest $request The request * @param IUserSession $userSession The user session */ - public function __construct($appName, IRequest $request, IUserSession $userSession) + public function __construct(string $appName, IRequest $request, IUserSession $userSession) { parent::__construct($appName, $request); $this->userSession = $userSession; diff --git a/lib/Controller/FeedApiController.php b/lib/Controller/FeedApiController.php index 400c1a4b2..ae2f8cdaf 100644 --- a/lib/Controller/FeedApiController.php +++ b/lib/Controller/FeedApiController.php @@ -15,12 +15,12 @@ namespace OCA\News\Controller; +use Exception; use OCA\News\Service\Exceptions\ServiceConflictException; use OCA\News\Service\Exceptions\ServiceNotFoundException; -use OCA\News\Utility\PsrLogger; +use OCA\News\Service\FeedServiceV2; use OCP\AppFramework\Http\JSONResponse; use \OCP\IRequest; -use \OCP\ILogger; use \OCP\IUserSession; use \OCP\AppFramework\Http; @@ -31,19 +31,26 @@ use function GuzzleHttp\Psr7\uri_for; class FeedApiController extends ApiController { - use JSONHttpErrorTrait; + use JSONHttpErrorTrait, ApiPayloadTrait; /** + * TODO: Remove * @var ItemService */ - private $itemService; + private $oldItemService; /** - * @var FeedService + * @var FeedServiceV2 */ private $feedService; /** + * TODO: Remove + * @var FeedService + */ + private $oldFeedService; + + /** * @var LoggerInterface */ private $logger; @@ -57,15 +64,16 @@ class FeedApiController extends ApiController string $appName, IRequest $re |