Fix updated entry filters (#6334)

fix https://github.com/FreshRSS/FreshRSS/issues/6331
This commit is contained in:
Alexandre Alapetite 2024-04-26 13:29:37 +02:00 committed by GitHub
parent d656896a95
commit 5ca0b893b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 2 deletions

View File

@ -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);

View File

@ -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<string> */
@ -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();

View File

@ -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;
}
}