aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Entry.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-09-04 10:09:37 +0200
committerGravatar GitHub <noreply@github.com> 2023-09-04 10:09:37 +0200
commit1c7c1016f4a5147003ed1c438b8a386a63a53cab (patch)
treea0639042ac205cd20863cd24496e79ddae3f562e /app/Models/Entry.php
parentda405ceee628dca739a12b234a6094a8ebae9c94 (diff)
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
Diffstat (limited to 'app/Models/Entry.php')
-rw-r--r--app/Models/Entry.php9
1 files changed, 6 insertions, 3 deletions
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<string> $labels List of labels associated to this entry.
* @return array<string,mixed> 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;
}