diff options
| author | 2021-09-19 10:56:38 +0200 | |
|---|---|---|
| committer | 2021-09-19 10:56:38 +0200 | |
| commit | a7aca6c0abfd905669004c1e4f7c8328060df27e (patch) | |
| tree | 3edd507ce9ce0762f0faf3c24108f3b1d24988e7 /app/Controllers | |
| parent | dfc89831d4e363f62dea9df71c6b4af21cc7d7c7 (diff) | |
Improved feed action filters (#3303)
* Re-order some feed options
* Option to auto mark as read existing titles
* Option to keep at max n unread articles per feed
Diffstat (limited to 'app/Controllers')
| -rwxr-xr-x | app/Controllers/configureController.php | 9 | ||||
| -rwxr-xr-x | app/Controllers/feedController.php | 26 | ||||
| -rw-r--r-- | app/Controllers/subscriptionController.php | 14 |
3 files changed, 42 insertions, 7 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 388c34624..79ddf8e17 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -121,9 +121,12 @@ class FreshRSS_configure_Controller extends Minz_ActionController { FreshRSS_Context::$user_conf->sort_order = Minz_Request::param('sort_order', 'DESC'); FreshRSS_Context::$user_conf->mark_when = array( 'article' => Minz_Request::param('mark_open_article', false), - 'site' => Minz_Request::param('mark_open_site', false), - 'scroll' => Minz_Request::param('mark_scroll', false), + 'max_n_unread' => Minz_Request::paramBoolean('enable_keep_max_n_unread') ? Minz_Request::param('keep_max_n_unread', false) : false, 'reception' => Minz_Request::param('mark_upon_reception', false), + 'same_title_in_feed' => Minz_Request::paramBoolean('enable_read_when_same_title_in_feed') ? + Minz_Request::param('read_when_same_title_in_feed', false) : false, + 'scroll' => Minz_Request::param('mark_scroll', false), + 'site' => Minz_Request::param('mark_open_site', false), ); FreshRSS_Context::$user_conf->save(); invalidateHttpCache(); @@ -210,7 +213,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { } elseif (!$keepMax = Minz_Request::param('keep_max')) { $keepMax = FreshRSS_Feed::ARCHIVING_RETENTION_COUNT_LIMIT; } - if ($enableRetentionPeriod = Minz_Request::paramBoolean('enable_keep_period')) { + if (Minz_Request::paramBoolean('enable_keep_period')) { $keepPeriod = FreshRSS_Feed::ARCHIVING_RETENTION_PERIOD; if (is_numeric(Minz_Request::param('keep_period_count')) && preg_match('/^PT?1[YMWDH]$/', Minz_Request::param('keep_period_unit'))) { $keepPeriod = str_replace('1', Minz_Request::param('keep_period_count'), Minz_Request::param('keep_period_unit')); diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index d43f05d4a..afb05f17e 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -359,6 +359,19 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $needFeedCacheRefresh = false; if (count($newGuids) > 0) { + $titlesAsRead = []; + $readWhenSameTitleInFeed = $feed->attributes('read_when_same_title_in_feed'); + if ($readWhenSameTitleInFeed == false) { + $readWhenSameTitleInFeed = FreshRSS_Context::$user_conf->mark_when['same_title_in_feed']; + } + if ($readWhenSameTitleInFeed > 0) { + $titlesAsRead = array_flip($feedDAO->listTitles($feed->id(), $feed->attributes('read_when_same_title_in_feed'))); + } + + $mark_updated_article_unread = $feed->attributes('mark_updated_article_unread') !== null ? ( + $feed->attributes('mark_updated_article_unread') + ) : FreshRSS_Context::$user_conf->mark_updated_article_unread; + // For this feed, check existing GUIDs already in database. $existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids); $newGuids = array(); @@ -379,11 +392,11 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } else { //This entry already exists but has been updated //Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->url(false) . //', old hash ' . $existingHash . ', new hash ' . $entry->hash()); - $mark_updated_article_unread = $feed->attributes('mark_updated_article_unread') !== null ? - $feed->attributes('mark_updated_article_unread') : - FreshRSS_Context::$user_conf->mark_updated_article_unread; $needFeedCacheRefresh = $mark_updated_article_unread; $entry->_isRead($mark_updated_article_unread ? false : null); //Change is_read according to policy. + if ($mark_updated_article_unread) { + $feed->incPendingUnread(); //Maybe + } $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); if ($entry === null) { @@ -403,7 +416,10 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $id = uTimeString(); $entry->_id($id); - $entry->applyFilterActions(); + $entry->applyFilterActions($titlesAsRead); + if ($readWhenSameTitleInFeed > 0) { + $titlesAsRead[$entry->title()] = true; + } $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); if ($entry === null) { @@ -424,6 +440,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $entryDAO->beginTransaction(); } $entryDAO->addEntry($entry->toArray()); + $feed->incPendingUnread(); $nb_new_articles++; } } @@ -445,6 +462,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if ($needFeedCacheRefresh) { $feedDAO->updateCachedValues($feed->id()); } + $feed->keepMaxUnread(); if ($entryDAO->inTransaction()) { $entryDAO->commit(); } diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index f47988926..4bb08f495 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -112,6 +112,20 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { $feed->_attributes('read_upon_reception', Minz_Request::paramTernary('read_upon_reception')); $feed->_attributes('clear_cache', Minz_Request::paramTernary('clear_cache')); + $keep_max_n_unread = intval(Minz_Request::param('keep_max_n_unread', 0)); + $feed->_attributes('keep_max_n_unread', $keep_max_n_unread > 0 ? $keep_max_n_unread : null); + + $read_when_same_title_in_feed = Minz_Request::param('read_when_same_title_in_feed', ''); + if ($read_when_same_title_in_feed === '') { + $read_when_same_title_in_feed = null; + } else { + $read_when_same_title_in_feed = intval($read_when_same_title_in_feed); + if ($read_when_same_title_in_feed <= 0) { + $read_when_same_title_in_feed = false; + } + } + $feed->_attributes('read_when_same_title_in_feed', $read_when_same_title_in_feed); + $cookie = Minz_Request::param('curl_params_cookie', ''); $useragent = Minz_Request::param('curl_params_useragent', ''); $proxy_address = Minz_Request::param('curl_params', ''); |
