aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/Controllers
diff options
context:
space:
mode:
authorAlexandre Alapetite <alexandre@alapetite.fr>2024-10-21 13:41:16 +0200
committerGitHub <noreply@github.com>2024-10-21 13:41:16 +0200
commitaea9ba0d62b86be05e53747c97bfcbc8f4bc4408 (patch)
tree5be022f67f0cd2fab8f7d09113e09608cdddc5aa /app/Controllers
parentad2c6e6fbf3658f08295fb437a0f97e10498eb11 (diff)
downloadfreshrss-aea9ba0d62b86be05e53747c97bfcbc8f4bc4408.tar.gz
freshrss-aea9ba0d62b86be05e53747c97bfcbc8f4bc4408.zip
New option mark article as read if identical title in category (#6922)
* New mark articles as read if identical title in category fix https://github.com/FreshRSS/FreshRSS/issues/6143 * i18n todo forgotten
Diffstat (limited to 'app/Controllers')
-rw-r--r--app/Controllers/categoryController.php6
-rwxr-xr-xapp/Controllers/feedController.php20
2 files changed, 24 insertions, 2 deletions
diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php
index 4d5c77596..181c4d811 100644
--- a/app/Controllers/categoryController.php
+++ b/app/Controllers/categoryController.php
@@ -100,6 +100,12 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController {
FreshRSS_View::prependTitle($category->name() . ' · ' . _t('sub.title') . ' · ');
if (Minz_Request::isPost()) {
+ if (Minz_Request::paramBoolean('enable_read_when_same_title_in_category')) {
+ $category->_attribute('read_when_same_title_in_category', Minz_Request::paramInt('read_when_same_title_in_category'));
+ } else {
+ $category->_attribute('read_when_same_title_in_category', null);
+ }
+
$category->_filtersAction('read', Minz_Request::paramTextToArray('filteractions_read'));
if (Minz_Request::paramBoolean('use_default_purge_options')) {
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index d285d69f9..89f3d65b1 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -409,6 +409,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$maxFeeds = PHP_INT_MAX;
}
+ $catDAO = FreshRSS_Factory::createCategoryDao();
$feedDAO = FreshRSS_Factory::createFeedDao();
$entryDAO = FreshRSS_Factory::createEntryDao();
@@ -425,7 +426,6 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
// Hydrate category for each feed to avoid that each feed has to make an SQL request
$categories = [];
- $catDAO = FreshRSS_Factory::createCategoryDao();
foreach ($catDAO->listCategories(false, false) as $category) {
$categories[$category->id()] = $category;
}
@@ -444,6 +444,8 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$nbUpdatedFeeds = 0;
$nbNewArticles = 0;
$feedsCacheToRefresh = [];
+ /** @var array<int,array<string,true>> */
+ $categoriesEntriesTitle = [];
foreach ($feeds as $feed) {
$feed = Minz_ExtensionManager::callHook('feed_before_actualize', $feed);
@@ -563,6 +565,14 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$titlesAsRead = [];
}
+ $category = $feed->category();
+ if (!isset($categoriesEntriesTitle[$feed->categoryId()]) && $category !== null && $category->hasAttribute('read_when_same_title_in_category')) {
+ $categoriesEntriesTitle[$feed->categoryId()] = array_fill_keys(
+ $catDAO->listTitles($feed->categoryId(), $category->attributeInt('read_when_same_title_in_category') ?? 0),
+ true
+ );
+ }
+
$mark_updated_article_unread = $feed->attributeBoolean('mark_updated_article_unread') ?? FreshRSS_Context::userConf()->mark_updated_article_unread;
// For this feed, check existing GUIDs already in database.
@@ -603,6 +613,9 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
if ($readWhenSameTitleInFeed > 0) {
$titlesAsRead[$entry->title()] = true;
}
+ if (isset($categoriesEntriesTitle[$feed->categoryId()])) {
+ $categoriesEntriesTitle[$feed->categoryId()][$entry->title()] = true;
+ }
if (!$entry->isRead()) {
$needFeedCacheRefresh = true; //Maybe
@@ -625,10 +638,13 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
continue;
}
- $entry->applyFilterActions($titlesAsRead);
+ $entry->applyFilterActions(array_merge($titlesAsRead, $categoriesEntriesTitle[$feed->categoryId()] ?? []));
if ($readWhenSameTitleInFeed > 0) {
$titlesAsRead[$entry->title()] = true;
}
+ if (isset($categoriesEntriesTitle[$feed->categoryId()])) {
+ $categoriesEntriesTitle[$feed->categoryId()][$entry->title()] = true;
+ }
$needFeedCacheRefresh = true;