aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Feed.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2022-06-25 11:15:51 +0200
committerGravatar GitHub <noreply@github.com> 2022-06-25 11:15:51 +0200
commitd785ddde2a00a9eadd38c45c528f2d2f6d1c356a (patch)
tree8583fb1a85a4a3da11a55c50fdbb0c521054d4c7 /app/Models/Feed.php
parent07a52137a975978dab762ac8276fd85919497013 (diff)
New option to automatically mark as read gone articles (#4426)
* New option to automatically mark as read gone articles Option to automatically and immediately mark as read entries / articles that are no longer provided in their upstream RSS / ATOM / XPath feed * Reduce SQL queries Optimisation: Perform cache update only once
Diffstat (limited to 'app/Models/Feed.php')
-rw-r--r--app/Models/Feed.php26
1 files changed, 24 insertions, 2 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index 1fc2eebf4..6f6b83af0 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -649,15 +649,37 @@ class FreshRSS_Feed extends Minz_Model {
$this->nbPendingNotRead += $n;
}
+ /**
+ * Remember to call updateCachedValue($id_feed) or updateCachedValues() just after.
+ * @return int|false the number of lines affected, or false if not applicable
+ */
public function keepMaxUnread() {
$keepMaxUnread = $this->attributes('keep_max_n_unread');
- if ($keepMaxUnread == false) {
+ if ($keepMaxUnread === null) {
$keepMaxUnread = FreshRSS_Context::$user_conf->mark_when['max_n_unread'];
}
if ($keepMaxUnread > 0 && $this->nbNotRead(false) + $this->nbPendingNotRead > $keepMaxUnread) {
$feedDAO = FreshRSS_Factory::createFeedDao();
- $feedDAO->keepMaxUnread($this->id(), max(0, $keepMaxUnread - $this->nbPendingNotRead));
+ return $feedDAO->keepMaxUnread($this->id(), max(0, $keepMaxUnread - $this->nbPendingNotRead));
}
+ return false;
+ }
+
+ /**
+ * Applies the *mark as read upon gone* policy, if enabled.
+ * Remember to call updateCachedValue($id_feed) or updateCachedValues() just after.
+ * @return int|false the number of lines affected, or false if not applicable
+ */
+ public function markAsReadUponGone() {
+ $readUponGone = $this->attributes('read_upon_gone');
+ if ($readUponGone === null) {
+ $readUponGone = FreshRSS_Context::$user_conf->mark_when['gone'];
+ }
+ if ($readUponGone) {
+ $feedDAO = FreshRSS_Factory::createFeedDao();
+ return $feedDAO->markAsReadUponGone($this->id());
+ }
+ return false;
}
/**