summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2021-02-02 13:31:22 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-02-02 16:07:38 +0100
commit66b4005b5ee832410742ee8ca3f07031dee38189 (patch)
tree90888ecf4c26e714ce8f59318e5f32d7c5f90572
parentf2b74a0ba1e762185b82e92379ce9e7366230c1e (diff)
Controllers: Export Starred or unread instead of and
Fixes GH-1010 Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
-rw-r--r--AUTHORS.md2
-rw-r--r--CHANGELOG.md2
-rw-r--r--lib/Controller/ExportController.php10
-rw-r--r--tests/Unit/Controller/ExportControllerTest.php6
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();