aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-05-01 17:02:11 +0200
committerGravatar GitHub <noreply@github.com> 2018-05-01 17:02:11 +0200
commitb552abb3327f09baa1c0f4e821dc9f6bd6ef738e (patch)
treedc5439bcf0e65d16fda118d45d2ded0c7ff7230c /app/Controllers
parent404ca869e9aafa40931914812b8552e4b9973694 (diff)
JSON column for feeds (#1838)
* Draft of JSON column for feeds https://github.com/FreshRSS/FreshRSS/issues/1654 * Add some per-feed options * Feed cURL timeout * Mark updated articles as read https://github.com/FreshRSS/FreshRSS/issues/891 * Mark as read upon reception https://github.com/FreshRSS/FreshRSS/issues/1702 * Ignore SSL (unsafe) https://github.com/FreshRSS/FreshRSS/issues/1811 * Try PHPCS workaround While waiting for a better syntax support
Diffstat (limited to 'app/Controllers')
-rwxr-xr-xapp/Controllers/feedController.php15
-rw-r--r--app/Controllers/subscriptionController.php19
2 files changed, 24 insertions, 10 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 59c22b777..ca85e7cb8 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -84,6 +84,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
'description' => $feed->description(),
'lastUpdate' => time(),
'httpAuth' => $feed->httpAuth(),
+ 'attributes' => array(),
);
$id = $feedDAO->addFeed($values);
@@ -271,7 +272,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$updated_feeds = 0;
$nb_new_articles = 0;
- $is_read = FreshRSS_Context::$user_conf->mark_when['reception'] ? 1 : 0;
foreach ($feeds as $feed) {
$url = $feed->url(); //For detection of HTTP 301
@@ -353,8 +353,10 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
} else { //This entry already exists but has been updated
//Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->id() .
//', old hash ' . $existingHash . ', new hash ' . $entry->hash());
- //TODO: Make an updated/is_read policy by feed, in addition to the global one.
- $needFeedCacheRefresh = FreshRSS_Context::$user_conf->mark_updated_article_unread;
+ $mark_updated_article_unread = $feed->attributes('mark_updated_article_unread') !== null ? (
+ $feed->attributes('mark_updated_article_unread')
+ ) : FreshRSS_Context::$user_conf->mark_updated_article_unread;
+ $needFeedCacheRefresh = $mark_updated_article_unread;
$entry->_isRead(FreshRSS_Context::$user_conf->mark_updated_article_unread ? false : null); //Change is_read according to policy.
if (!$entryDAO->inTransaction()) {
$entryDAO->beginTransaction();
@@ -365,15 +367,18 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
// This entry should not be added considering configuration and date.
$oldGuids[] = $entry->guid();
} else {
+ $read_upon_reception = $feed->attributes('read_upon_reception') !== null ? (
+ $feed->attributes('read_upon_reception')
+ ) : FreshRSS_Context::$user_conf->mark_when['reception'];
if ($isNewFeed) {
$id = min(time(), $entry_date) . uSecString();
- $entry->_isRead($is_read);
+ $entry->_isRead($read_upon_reception);
} elseif ($entry_date < $date_min) {
$id = min(time(), $entry_date) . uSecString();
$entry->_isRead(true); //Old article that was not in database. Probably an error, so mark as read
} else {
$id = uTimeString();
- $entry->_isRead($is_read);
+ $entry->_isRead($read_upon_reception);
}
$entry->_id($id);
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index 37efd3b57..860cd912f 100644
--- a/app/Controllers/subscriptionController.php
+++ b/app/Controllers/subscriptionController.php
@@ -15,7 +15,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
}
$catDAO = new FreshRSS_CategoryDAO();
- $feedDAO = new FreshRSS_FeedDAO();
+ $feedDAO = FreshRSS_Factory::createFeedDao();
$catDAO->checkDefault();
$feedDAO->updateTTL();
@@ -74,9 +74,10 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
return;
}
- $this->view->feed = $this->view->feeds[$id];
+ $feed = $this->view->feeds[$id];
+ $this->view->feed = $feed;
- Minz_View::prependTitle(_t('sub.title.feed_management') . ' · ' . $this->view->feed->name() . ' · ');
+ Minz_View::prependTitle(_t('sub.title.feed_management') . ' · ' . $feed->name() . ' · ');
if (Minz_Request::isPost()) {
$user = trim(Minz_Request::param('http_user_feed' . $id, ''));
@@ -95,6 +96,13 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
$ttl = FreshRSS_Context::$user_conf->ttl_default;
}
+ $feed->_attributes('mark_updated_article_unread', Minz_Request::paramTernary('mark_updated_article_unread'));
+ $feed->_attributes('read_upon_reception', Minz_Request::paramTernary('read_upon_reception'));
+ $feed->_attributes('ssl_verify', Minz_Request::paramTernary('ssl_verify'));
+
+ $timeout = intval(Minz_Request::param('timeout', 0));
+ $feed->_attributes('timeout', $timeout > 0 ? $timeout : null);
+
$values = array(
'name' => Minz_Request::param('name', ''),
'description' => sanitizeHTML(Minz_Request::param('description', '', true)),
@@ -106,14 +114,15 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
'httpAuth' => $httpAuth,
'keep_history' => intval(Minz_Request::param('keep_history', FreshRSS_Feed::KEEP_HISTORY_DEFAULT)),
'ttl' => $ttl * ($mute ? -1 : 1),
+ 'attributes' => $feed->attributes()
);
invalidateHttpCache();
$url_redirect = array('c' => 'subscription', 'params' => array('id' => $id));
if ($feedDAO->updateFeed($id, $values) !== false) {
- $this->view->feed->_category($cat);
- $this->view->feed->faviconPrepare();
+ $feed->_category($cat);
+ $feed->faviconPrepare();
Minz_Request::good(_t('feedback.sub.feed.updated'), $url_redirect);
} else {