diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 5e364ffcd..3b3bd6ed0 100644 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -573,6 +573,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { $existingHash = $existingHashForGuids[$entry->guid()]; if (strcasecmp($existingHash, $entry->hash()) !== 0) { //This entry already exists but has been updated + $entry->_isUpdated(true); //Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->url(false) . //', old hash ' . $existingHash . ', new hash ' . $entry->hash()); $entry->_isFavorite(null); // Do not change favourite state @@ -587,6 +588,11 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { continue; } + $entry->applyFilterActions($titlesAsRead); + if ($readWhenSameTitleInFeed > 0) { + $titlesAsRead[$entry->title()] = true; + } + if (!$entry->isRead()) { $needFeedCacheRefresh = true; //Maybe $nbMarkedUnread++; @@ -601,6 +607,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { $entryDAO->updateEntry($entry->toArray()); } } else { + $entry->_isUpdated(false); $id = uTimeString(); $entry->_id($id); diff --git a/app/Models/Entry.php b/app/Models/Entry.php index c5a9ddc7e..6e59c063a 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -24,6 +24,7 @@ class FreshRSS_Entry extends Minz_Model { private string $hash = ''; private ?bool $is_read; private ?bool $is_favorite; + private bool $is_updated = false; private int $feedId; private ?FreshRSS_Feed $feed; /** @var array */ @@ -394,6 +395,18 @@ HTML; return $this->is_favorite; } + /** + * Returns whether the entry has been modified since it was inserted in database. + * @returns bool `true` if the entry already existed (and has been modified), `false` if the entry is new (or unmodified). + */ + public function isUpdated(): ?bool { + return $this->is_updated; + } + + public function _isUpdated(bool $value): void { + $this->is_updated = $value; + } + public function feed(): ?FreshRSS_Feed { if ($this->feed === null) { $feedDAO = FreshRSS_Factory::createFeedDao(); diff --git a/app/Models/FilterActionsTrait.php b/app/Models/FilterActionsTrait.php index a19c0a361..57e3d8f12 100644 --- a/app/Models/FilterActionsTrait.php +++ b/app/Models/FilterActionsTrait.php @@ -135,10 +135,16 @@ trait FreshRSS_FilterActionsTrait { } break; case 'star': - $entry->_isFavorite(true); + if (!$entry->isUpdated()) { + // Do not apply to updated articles, to avoid overruling a user manual action + $entry->_isFavorite(true); + } break; case 'label': - $applyLabel = true; + if (!$entry->isUpdated()) { + // Do not apply to updated articles, to avoid overruling a user manual action + $applyLabel = true; + } break; } }