From 66b4005b5ee832410742ee8ca3f07031dee38189 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Tue, 2 Feb 2021 13:31:22 +0100 Subject: Controllers: Export Starred or unread instead of and Fixes GH-1010 Signed-off-by: Sean Molenaar --- AUTHORS.md | 2 +- CHANGELOG.md | 2 ++ lib/Controller/ExportController.php | 10 +++++++++- tests/Unit/Controller/ExportControllerTest.php | 6 +++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 6e4a6689f..89571c36c 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -3,8 +3,8 @@ * [Alessandro Cosentino](mailto:cosenal@gmail.com) * [Benjamin Brahmer](mailto:info@b-brahmer.de) * [Robin Appelman](mailto:icewind@owncloud.com) -* [Gregor Tätzner](mailto:gregor@freenet.de) * [Sean Molenaar](mailto:sean@seanmolenaar.eu) +* [Gregor Tätzner](mailto:gregor@freenet.de) * [Morris Jobke](mailto:hey@morrisjobke.de) * [Sean Molenaar](mailto:SMillerDev@users.noreply.github.com) * [anoy](mailto:anoymouserver+github@mailbox.org) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f3b7a83b..e4889fa7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ The format is almost based on [Keep a Changelog](https://keepachangelog.com/en/1 ### Fixed - Item purger does not work with PostgreSQL (#1094) +- Export starred/unread correctly (#1010) + ## [15.2.0-rc1] - 2021-01-31 ### Changed diff --git a/lib/Controller/ExportController.php b/lib/Controller/ExportController.php index ad1975639..959881888 100644 --- a/lib/Controller/ExportController.php +++ b/lib/Controller/ExportController.php @@ -22,6 +22,11 @@ use \OCP\IRequest; use \OCP\AppFramework\Http\JSONResponse; use OCP\IUserSession; +/** + * Class ExportController + * + * @package OCA\News\Controller + */ class ExportController extends Controller { @@ -69,7 +74,10 @@ class ExportController extends Controller public function articles(): JSONResponse { $feeds = $this->feedService->findAllForUser($this->getUserId()); - $items = $this->itemService->findAllForUser($this->getUserId(), ['unread' => true, 'starred' => true]); + $starred = $this->itemService->findAllForUser($this->getUserId(), ['unread' => false, 'starred' => true]); + $unread = $this->itemService->findAllForUser($this->getUserId(), ['unread' => true]); + + $items = array_merge($starred, $unread); // build assoc array for fast access $feedsDict = []; diff --git a/tests/Unit/Controller/ExportControllerTest.php b/tests/Unit/Controller/ExportControllerTest.php index 1565daf81..cb21822be 100644 --- a/tests/Unit/Controller/ExportControllerTest.php +++ b/tests/Unit/Controller/ExportControllerTest.php @@ -141,10 +141,10 @@ class ExportControllerTest extends TestCase ->method('findAllForUser') ->with('user') ->will($this->returnValue($feeds)); - $this->itemService->expects($this->once()) + $this->itemService->expects($this->exactly(2)) ->method('findAllForUser') - ->with('user', ['unread' => true, 'starred' => true]) - ->will($this->returnValue($articles)); + ->withConsecutive(['user', ['unread' => false, 'starred' => true]], ['user', ['unread' => true]]) + ->willReturnOnConsecutiveCalls($articles, []); $return = $this->controller->articles(); -- cgit v1.2.3