From 509c8cae6381ec46af7c8303eb92fda6ce496a4a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 4 Jul 2022 09:53:26 +0200 Subject: Dynamic OPML (#4407) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- app/Models/Feed.php | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'app/Models/Feed.php') 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; } -- cgit v1.2.3