aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Feed.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2022-07-04 09:53:26 +0200
committerGravatar GitHub <noreply@github.com> 2022-07-04 09:53:26 +0200
commit509c8cae6381ec46af7c8303eb92fda6ce496a4a (patch)
tree653f7f44df842f9d7135decd89467879a0098c50 /app/Models/Feed.php
parent57d571230eeb2d3ede57e640b640f17c7a2298a2 (diff)
Dynamic OPML (#4407)
* Dynamic OPML draft #fix https://github.com/FreshRSS/FreshRSS/issues/4191 * Export dynamic OPML http://opml.org/spec2.opml#1629043127000 * Restart with simpler approach * Minor revert * Export dynamic OPML also for single feeds * Special category type for importing dynamic OPML * Parameter for excludeMutedFeeds * Details * More draft * i18n * Fix update * Draft manual import working * Working manual refresh * Draft automatic update * Working Web refresh + fixes * Import/export dynamic OPML settings * Annoying numerous lines in SQL logs * Fix minor JavaScript error * Fix auto adding new columns * Add require * Add missing 🗲 * Missing space * Disable adding new feeds to dynamic categories * Link from import * i18n typo * Improve theme icon function * Fix pink-dark
Diffstat (limited to 'app/Models/Feed.php')
-rw-r--r--app/Models/Feed.php35
1 files changed, 23 insertions, 12 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index 6f6b83af0..e39109b49 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -162,9 +162,21 @@ class FreshRSS_Feed extends Minz_Model {
public function inError(): bool {
return $this->error;
}
- public function ttl(): int {
+
+ /**
+ * @param bool $raw true for database version combined with mute information, false otherwise
+ */
+ public function ttl(bool $raw = false): int {
+ if ($raw) {
+ $ttl = $this->ttl;
+ if ($this->mute && FreshRSS_Feed::TTL_DEFAULT === $ttl) {
+ $ttl = FreshRSS_Context::$user_conf ? FreshRSS_Context::$user_conf->ttl_default : 3600;
+ }
+ return $ttl * ($this->mute ? -1 : 1);
+ }
return $this->ttl;
}
+
public function attributes($key = '') {
if ($key == '') {
return $this->attributes;
@@ -172,19 +184,11 @@ class FreshRSS_Feed extends Minz_Model {
return isset($this->attributes[$key]) ? $this->attributes[$key] : null;
}
}
+
public function mute(): bool {
return $this->mute;
}
- // public function ttlExpire() {
- // $ttl = $this->ttl;
- // if ($ttl == self::TTL_DEFAULT) { //Default
- // $ttl = FreshRSS_Context::$user_conf->ttl_default;
- // }
- // if ($ttl == -1) { //Never
- // $ttl = 64000000; //~2 years. Good enough for PubSubHubbub logic
- // }
- // return $this->lastUpdate + $ttl;
- // }
+
public function nbEntries(): int {
if ($this->nbEntries < 0) {
$feedDAO = FreshRSS_Factory::createFeedDao();
@@ -248,10 +252,13 @@ class FreshRSS_Feed extends Minz_Model {
public function _kind(int $value) {
$this->kind = $value;
}
+
+ /** @param int $value */
public function _category($value) {
$value = intval($value);
$this->category = $value >= 0 ? $value : 0;
}
+
public function _name(string $value) {
$this->name = $value == '' ? '' : trim($value);
}
@@ -282,6 +289,9 @@ class FreshRSS_Feed extends Minz_Model {
public function _error($value) {
$this->error = (bool)$value;
}
+ public function _mute(bool $value) {
+ $this->mute = $value;
+ }
public function _ttl($value) {
$value = intval($value);
$value = min($value, 100000000);
@@ -584,7 +594,8 @@ class FreshRSS_Feed extends Minz_Model {
return null;
}
- $html = getHtml($feedSourceUrl, $attributes);
+ $cachePath = FreshRSS_Feed::cacheFilename($feedSourceUrl, $attributes, FreshRSS_Feed::KIND_HTML_XPATH);
+ $html = httpGet($feedSourceUrl, $cachePath, 'html', $attributes);
if (strlen($html) <= 0) {
return null;
}