diff options
Diffstat (limited to 'lib/Controller/FeedApiController.php')
-rw-r--r-- | lib/Controller/FeedApiController.php | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/lib/Controller/FeedApiController.php b/lib/Controller/FeedApiController.php index f247a4e66..43d92b7ca 100644 --- a/lib/Controller/FeedApiController.php +++ b/lib/Controller/FeedApiController.php @@ -19,12 +19,12 @@ use Exception; use OCA\News\Service\Exceptions\ServiceConflictException; use OCA\News\Service\Exceptions\ServiceNotFoundException; use OCA\News\Service\FeedServiceV2; +use OCA\News\Service\ItemServiceV2; use OCP\AppFramework\Http\JSONResponse; use \OCP\IRequest; use \OCP\IUserSession; use \OCP\AppFramework\Http; -use \OCA\News\Service\ItemService; use Psr\Log\LoggerInterface; class FeedApiController extends ApiController @@ -32,10 +32,9 @@ class FeedApiController extends ApiController use JSONHttpErrorTrait, ApiPayloadTrait; /** - * TODO: Remove - * @var ItemService + * @var ItemServiceV2 */ - private $oldItemService; + private $itemService; /** * @var FeedServiceV2 @@ -51,12 +50,12 @@ class FeedApiController extends ApiController IRequest $request, ?IUserSession $userSession, FeedServiceV2 $feedService, - ItemService $oldItemService, + ItemServiceV2 $itemService, LoggerInterface $logger ) { parent::__construct($request, $userSession); $this->feedService = $feedService; - $this->oldItemService = $oldItemService; + $this->itemService = $itemService; $this->logger = $logger; } @@ -70,12 +69,12 @@ class FeedApiController extends ApiController { $result = [ - 'starredCount' => $this->oldItemService->starredCount($this->getUserId()), + 'starredCount' => count($this->itemService->starred($this->getUserId())), 'feeds' => $this->serialize($this->feedService->findAllForUser($this->getUserId())) ]; try { - $result['newestItemId'] = $this->oldItemService->getNewestItemId($this->getUserId()); + $result['newestItemId'] = $this->itemService->newest($this->getUserId())->getId(); } catch (ServiceNotFoundException $ex) { // in case there are no items, ignore } @@ -96,9 +95,7 @@ class FeedApiController extends ApiController */ public function create(string $url, ?int $folderId = null) { - if ($folderId === 0) { - $folderId = null; - } + $folderId = $folderId === 0 ? null : $folderId; try { $this->feedService->purgeDeleted($this->getUserId(), time() - 600); @@ -109,7 +106,7 @@ class FeedApiController extends ApiController $this->feedService->fetch($feed); try { - $result['newestItemId'] = $this->oldItemService->getNewestItemId($this->getUserId()); + $result['newestItemId'] = $this->itemService->newest($this->getUserId())->getId(); } catch (ServiceNotFoundException $ex) { // in case there are no items, ignore } @@ -154,7 +151,7 @@ class FeedApiController extends ApiController */ public function read(int $feedId, int $newestItemId): void { - $this->oldItemService->readFeed($feedId, $newestItemId, $this->getUserId()); + $this->itemService->read($this->getUserId(), $feedId, $newestItemId); } @@ -170,9 +167,7 @@ class FeedApiController extends ApiController */ public function move(int $feedId, ?int $folderId) { - if ($folderId === 0) { - $folderId = null; - } + $folderId = $folderId === 0 ? null : $folderId; try { $feed = $this->feedService->find($this->getUserId(), $feedId); |