From 1c7c1016f4a5147003ed1c438b8a386a63a53cab Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 4 Sep 2023 10:09:37 +0200 Subject: Fix JSON export/import (#5626) * Fix import with empty content fix https://github.com/FreshRSS/FreshRSS/issues/5622 Cherry picks on https://github.com/FreshRSS/FreshRSS/pull/5584 * Fix export of tags / labels Article-defined tags were wrongly exported as user-defined labels. * Fix export of tags / labels Article-defined tags were wrongly exported as user-defined labels. * Fix bug with many labels * Better typing * Comments --- app/Models/Entry.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'app/Models/Entry.php') diff --git a/app/Models/Entry.php b/app/Models/Entry.php index 7da27e409..b70e7e2ab 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -846,12 +846,12 @@ HTML; /** * N.B.: To avoid expensive lookups, ensure to set `$entry->_feed($feed)` before calling this function. - * N.B.: You might have to populate `$entry->_tags()` prior to calling this function. * @param string $mode Set to `'compat'` to use an alternative Unicode representation for problematic HTML special characters not decoded by some clients; * set to `'freshrss'` for using FreshRSS additions for internal use (e.g. export/import). + * @param array $labels List of labels associated to this entry. * @return array A representation of this entry in a format compatible with Google Reader API */ - public function toGReader(string $mode = ''): array { + public function toGReader(string $mode = '', array $labels = []): array { $feed = $this->feed(); $category = $feed == null ? null : $feed->category(); @@ -935,8 +935,11 @@ HTML; if ($this->isFavorite()) { $item['categories'][] = 'user/-/state/com.google/starred'; } + foreach ($labels as $labelName) { + $item['categories'][] = 'user/-/label/' . htmlspecialchars_decode($labelName, ENT_QUOTES); + } foreach ($this->tags() as $tagName) { - $item['categories'][] = 'user/-/label/' . htmlspecialchars_decode($tagName, ENT_QUOTES); + $item['categories'][] = htmlspecialchars_decode($tagName, ENT_QUOTES); } return $item; } -- cgit v1.2.3