summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-01-24 20:44:45 +0100
committerGravatar GitHub <noreply@github.com> 2019-01-24 20:44:45 +0100
commitf1ac6dd5509c6aa9e1d99401c5e1a0b894d4e7b0 (patch)
tree5d71ca953834af2e918820a2a47b25e3fc2143c0
parentf0684d701862d103fce834bad9e139f97544bc62 (diff)
Export/import articles read/unread state (#2226)
-rw-r--r--CHANGELOG.md1
-rw-r--r--app/Controllers/importExportController.php10
-rw-r--r--app/views/helpers/export/articles.phtml1
3 files changed, 11 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3a0188431..3e3dfc302 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
* Features
* Include articles with custom labels during export [#2196](https://github.com/FreshRSS/FreshRSS/issues/2196)
+ * Export/import articles read/unread state [#2226](https://github.com/FreshRSS/FreshRSS/pull/2226)
* Bug fixing
* Fix missing HTTP `X-Forwarded-Prefix` in cookie path behind a reverse-proxy [#2201](https://github.com/FreshRSS/FreshRSS/pull/2201)
* Deployment
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php
index 96c5e42c2..e11221610 100644
--- a/app/Controllers/importExportController.php
+++ b/app/Controllers/importExportController.php
@@ -436,7 +436,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
return false;
}
- $is_read = FreshRSS_Context::$user_conf->mark_when['reception'] ? 1 : 0;
+ $mark_as_read = FreshRSS_Context::$user_conf->mark_when['reception'] ? 1 : 0;
$google_compliant = strpos($article_object['id'], 'com.google') !== false;
@@ -507,6 +507,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
$feed_id = $article_to_feed[$item['id']];
$author = isset($item['author']) ? $item['author'] : '';
$is_starred = false;
+ $is_read = null;
$tags = $item['categories'];
$labels = array();
for ($i = count($tags) - 1; $i >= 0; $i --) {
@@ -514,6 +515,10 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
if (strpos($tag, 'user/-/') !== false) {
if ($tag === 'user/-/state/com.google/starred') {
$is_starred = true;
+ } elseif ($tag === 'user/-/state/com.google/read') {
+ $is_read = true;
+ } elseif ($tag === 'user/-/state/com.google/unread') {
+ $is_read = false;
} elseif (strpos($tag, 'user/-/label/') === 0) {
$tag = trim(substr($tag, 13));
if ($tag != '') {
@@ -527,6 +532,9 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
//If the article has no label, mark it as starred (old format)
$is_starred = empty($labels);
}
+ if ($is_read === null) {
+ $is_read = $mark_as_read;
+ }
$url = $item['alternate'][0]['href'];
if (!empty($item['content']['content'])) {
diff --git a/app/views/helpers/export/articles.phtml b/app/views/helpers/export/articles.phtml
index eb2cb0924..2d1fcd133 100644
--- a/app/views/helpers/export/articles.phtml
+++ b/app/views/helpers/export/articles.phtml
@@ -56,6 +56,7 @@ foreach ($this->entriesRaw as $entryRaw) {
'feedUrl' => $feed == null ? '' : $feed->url(),
)
);
+ $article['categories'][] = $entry->isRead() ? 'user/-/state/com.google/read' : 'user/-/state/com.google/unread';
if ($entry->isFavorite()) {
$article['categories'][] = 'user/-/state/com.google/starred';
}