Archive cleanup:
- remove code to manually archive/unarchive articles - remove ttrss_archived_feeds/orig_feed_id handling - the whole thing was implemented for this data to be kept indefinitely; it doesn't make a lot of sense to deal with this stuff now that it is expired after one month anyway (same reasons as feed browser being removed - privacy) - remove "originally from"-related stuff because of the above - also remove unused remaining frontend/backend code related to feed browser (rip)
This commit is contained in:
parent
6c13449088
commit
da0ad82c24
|
@ -350,19 +350,6 @@ class Feeds extends Handler_Protected {
|
||||||
|
|
||||||
$this->mark_timestamp(" enclosures");
|
$this->mark_timestamp(" enclosures");
|
||||||
|
|
||||||
if ($line["orig_feed_id"]) {
|
|
||||||
|
|
||||||
$ofgh = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds
|
|
||||||
WHERE id = ? AND owner_uid = ?");
|
|
||||||
$ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]);
|
|
||||||
|
|
||||||
if ($tmp_line = $ofgh->fetch()) {
|
|
||||||
$line["orig_feed"] = [ $tmp_line["title"], $tmp_line["site_url"], $tmp_line["feed_url"] ];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->mark_timestamp(" orig-feed-id");
|
|
||||||
|
|
||||||
$line["updated_long"] = TimeHelper::make_local_datetime($line["updated"],true);
|
$line["updated_long"] = TimeHelper::make_local_datetime($line["updated"],true);
|
||||||
$line["updated"] = TimeHelper::make_local_datetime($line["updated"], false, false, false, true);
|
$line["updated"] = TimeHelper::make_local_datetime($line["updated"], false, false, false, true);
|
||||||
|
|
||||||
|
@ -1840,7 +1827,7 @@ class Feeds extends Handler_Protected {
|
||||||
uuid,
|
uuid,
|
||||||
lang,
|
lang,
|
||||||
hide_images,
|
hide_images,
|
||||||
unread,feed_id,marked,published,link,last_read,orig_feed_id,
|
unread,feed_id,marked,published,link,last_read,
|
||||||
last_marked, last_published,
|
last_marked, last_published,
|
||||||
$vfeed_query_part
|
$vfeed_query_part
|
||||||
$content_query_part
|
$content_query_part
|
||||||
|
@ -1884,7 +1871,6 @@ class Feeds extends Handler_Protected {
|
||||||
updated,
|
updated,
|
||||||
unread,
|
unread,
|
||||||
feed_id,
|
feed_id,
|
||||||
orig_feed_id,
|
|
||||||
marked,
|
marked,
|
||||||
published,
|
published,
|
||||||
num_comments,
|
num_comments,
|
||||||
|
|
|
@ -328,7 +328,6 @@ class Handler_Public extends Handler {
|
||||||
tag_cache,
|
tag_cache,
|
||||||
author,
|
author,
|
||||||
guid,
|
guid,
|
||||||
orig_feed_id,
|
|
||||||
note
|
note
|
||||||
FROM ttrss_entries,ttrss_user_entries
|
FROM ttrss_entries,ttrss_user_entries
|
||||||
WHERE id = ? AND ref_id = id AND owner_uid = ?");
|
WHERE id = ? AND ref_id = id AND owner_uid = ?");
|
||||||
|
|
|
@ -1607,42 +1607,12 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
|
|
||||||
/* save starred articles in Archived feed */
|
/* save starred articles in Archived feed */
|
||||||
|
|
||||||
/* prepare feed if necessary */
|
$sth = $pdo->prepare("UPDATE ttrss_user_entries SET
|
||||||
|
feed_id = NULL, orig_feed_id = NULL
|
||||||
|
WHERE feed_id = ? AND marked = true AND owner_uid = ?");
|
||||||
|
|
||||||
$sth = $pdo->prepare("SELECT feed_url FROM ttrss_feeds WHERE id = ?
|
|
||||||
AND owner_uid = ?");
|
|
||||||
$sth->execute([$id, $owner_uid]);
|
$sth->execute([$id, $owner_uid]);
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
|
||||||
$feed_url = $row["feed_url"];
|
|
||||||
|
|
||||||
$sth = $pdo->prepare("SELECT id FROM ttrss_archived_feeds
|
|
||||||
WHERE feed_url = ? AND owner_uid = ?");
|
|
||||||
$sth->execute([$feed_url, $owner_uid]);
|
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
|
||||||
$archive_id = $row["id"];
|
|
||||||
} else {
|
|
||||||
$res = $pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds");
|
|
||||||
$row = $res->fetch();
|
|
||||||
|
|
||||||
$new_feed_id = (int)$row['id'] + 1;
|
|
||||||
|
|
||||||
$sth = $pdo->prepare("INSERT INTO ttrss_archived_feeds
|
|
||||||
(id, owner_uid, title, feed_url, site_url, created)
|
|
||||||
SELECT ?, owner_uid, title, feed_url, site_url, NOW() from ttrss_feeds
|
|
||||||
WHERE id = ?");
|
|
||||||
$sth->execute([$new_feed_id, $id]);
|
|
||||||
|
|
||||||
$archive_id = $new_feed_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sth = $pdo->prepare("UPDATE ttrss_user_entries SET feed_id = NULL,
|
|
||||||
orig_feed_id = ? WHERE feed_id = ? AND
|
|
||||||
marked = true AND owner_uid = ?");
|
|
||||||
|
|
||||||
$sth->execute([$archive_id, $id, $owner_uid]);
|
|
||||||
|
|
||||||
/* Remove access key for the feed */
|
/* Remove access key for the feed */
|
||||||
|
|
||||||
$sth = $pdo->prepare("DELETE FROM ttrss_access_keys WHERE
|
$sth = $pdo->prepare("DELETE FROM ttrss_access_keys WHERE
|
||||||
|
@ -1654,7 +1624,6 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
$sth = $pdo->prepare("DELETE FROM ttrss_feeds
|
$sth = $pdo->prepare("DELETE FROM ttrss_feeds
|
||||||
WHERE id = ? AND owner_uid = ?");
|
WHERE id = ? AND owner_uid = ?");
|
||||||
$sth->execute([$id, $owner_uid]);
|
$sth->execute([$id, $owner_uid]);
|
||||||
}
|
|
||||||
|
|
||||||
$pdo->commit();
|
$pdo->commit();
|
||||||
|
|
||||||
|
|
175
classes/rpc.php
175
classes/rpc.php
|
@ -80,20 +80,6 @@ class RPC extends Handler_Protected {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Silent
|
|
||||||
function remarchive() {
|
|
||||||
$ids = explode(",", clean($_REQUEST["ids"]));
|
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("DELETE FROM ttrss_archived_feeds WHERE
|
|
||||||
(SELECT COUNT(*) FROM ttrss_user_entries
|
|
||||||
WHERE orig_feed_id = :id) = 0 AND
|
|
||||||
id = :id AND owner_uid = :uid");
|
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
|
||||||
$sth->execute([":id" => $id, ":uid" => $_SESSION['uid']]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addfeed() {
|
function addfeed() {
|
||||||
$feed = clean($_REQUEST['feed']);
|
$feed = clean($_REQUEST['feed']);
|
||||||
$cat = clean($_REQUEST['cat']);
|
$cat = clean($_REQUEST['cat']);
|
||||||
|
@ -150,113 +136,6 @@ class RPC extends Handler_Protected {
|
||||||
print json_encode(array("message" => "UPDATE_COUNTERS"));
|
print json_encode(array("message" => "UPDATE_COUNTERS"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function unarchive() {
|
|
||||||
$ids = explode(",", clean($_REQUEST["ids"]));
|
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
|
||||||
$this->pdo->beginTransaction();
|
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("SELECT feed_url,site_url,title FROM ttrss_archived_feeds
|
|
||||||
WHERE id = (SELECT orig_feed_id FROM ttrss_user_entries WHERE ref_id = :id
|
|
||||||
AND owner_uid = :uid) AND owner_uid = :uid");
|
|
||||||
$sth->execute([":uid" => $_SESSION['uid'], ":id" => $id]);
|
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
|
||||||
$feed_url = $row['feed_url'];
|
|
||||||
$site_url = $row['site_url'];
|
|
||||||
$title = $row['title'];
|
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ?
|
|
||||||
AND owner_uid = ?");
|
|
||||||
$sth->execute([$feed_url, $_SESSION['uid']]);
|
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
|
||||||
$feed_id = $row["id"];
|
|
||||||
} else {
|
|
||||||
if (!$title) $title = '[Unknown]';
|
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
|
|
||||||
(owner_uid,feed_url,site_url,title,cat_id,auth_login,auth_pass,update_method)
|
|
||||||
VALUES (?, ?, ?, ?, NULL, '', '', 0)");
|
|
||||||
$sth->execute([$_SESSION['uid'], $feed_url, $site_url, $title]);
|
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ?
|
|
||||||
AND owner_uid = ?");
|
|
||||||
$sth->execute([$feed_url, $_SESSION['uid']]);
|
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
|
||||||
$feed_id = $row['id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($feed_id) {
|
|
||||||
$sth = $this->pdo->prepare("UPDATE ttrss_user_entries
|
|
||||||
SET feed_id = ?, orig_feed_id = NULL
|
|
||||||
WHERE ref_id = ? AND owner_uid = ?");
|
|
||||||
$sth->execute([$feed_id, $id, $_SESSION['uid']]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->pdo->commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
print json_encode(array("message" => "UPDATE_COUNTERS"));
|
|
||||||
}
|
|
||||||
|
|
||||||
function archive() {
|
|
||||||
$ids = explode(",", clean($_REQUEST["ids"]));
|
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
|
||||||
$this->archive_article($id, $_SESSION["uid"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
print json_encode(array("message" => "UPDATE_COUNTERS"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function archive_article($id, $owner_uid) {
|
|
||||||
$this->pdo->beginTransaction();
|
|
||||||
|
|
||||||
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
|
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("SELECT feed_id FROM ttrss_user_entries
|
|
||||||
WHERE ref_id = ? AND owner_uid = ?");
|
|
||||||
$sth->execute([$id, $owner_uid]);
|
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
|
||||||
|
|
||||||
/* prepare the archived table */
|
|
||||||
|
|
||||||
$feed_id = (int) $row['feed_id'];
|
|
||||||
|
|
||||||
if ($feed_id) {
|
|
||||||
$sth = $this->pdo->prepare("SELECT id FROM ttrss_archived_feeds
|
|
||||||
WHERE id = ? AND owner_uid = ?");
|
|
||||||
$sth->execute([$feed_id, $owner_uid]);
|
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
|
||||||
$new_feed_id = $row['id'];
|
|
||||||
} else {
|
|
||||||
$row = $this->pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds")->fetch();
|
|
||||||
$new_feed_id = (int)$row['id'] + 1;
|
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("INSERT INTO ttrss_archived_feeds
|
|
||||||
(id, owner_uid, title, feed_url, site_url, created)
|
|
||||||
SELECT ?, owner_uid, title, feed_url, site_url, NOW() from ttrss_feeds
|
|
||||||
WHERE id = ?");
|
|
||||||
|
|
||||||
$sth->execute([$new_feed_id, $feed_id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("UPDATE ttrss_user_entries
|
|
||||||
SET orig_feed_id = ?, feed_id = NULL
|
|
||||||
WHERE ref_id = ? AND owner_uid = ?");
|
|
||||||
$sth->execute([$new_feed_id, $id, $owner_uid]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->pdo->commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
function publ() {
|
function publ() {
|
||||||
$pub = clean($_REQUEST["pub"]);
|
$pub = clean($_REQUEST["pub"]);
|
||||||
$id = clean($_REQUEST["id"]);
|
$id = clean($_REQUEST["id"]);
|
||||||
|
@ -347,60 +226,6 @@ class RPC extends Handler_Protected {
|
||||||
print "</ul>";
|
print "</ul>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Silent
|
|
||||||
function massSubscribe() {
|
|
||||||
|
|
||||||
$payload = json_decode(clean($_REQUEST["payload"]), false);
|
|
||||||
$mode = clean($_REQUEST["mode"]);
|
|
||||||
|
|
||||||
if (!$payload || !is_array($payload)) return;
|
|
||||||
|
|
||||||
if ($mode == 1) {
|
|
||||||
foreach ($payload as $feed) {
|
|
||||||
|
|
||||||
$title = $feed[0];
|
|
||||||
$feed_url = $feed[1];
|
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
|
|
||||||
feed_url = ? AND owner_uid = ?");
|
|
||||||
$sth->execute([$feed_url, $_SESSION['uid']]);
|
|
||||||
|
|
||||||
if (!$sth->fetch()) {
|
|
||||||
$sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
|
|
||||||
(owner_uid,feed_url,title,cat_id,site_url)
|
|
||||||
VALUES (?, ?, ?, NULL, '')");
|
|
||||||
|
|
||||||
$sth->execute([$_SESSION['uid'], $feed_url, $title]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ($mode == 2) {
|
|
||||||
// feed archive
|
|
||||||
foreach ($payload as $id) {
|
|
||||||
$sth = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds
|
|
||||||
WHERE id = ? AND owner_uid = ?");
|
|
||||||
$sth->execute([$id, $_SESSION['uid']]);
|
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
|
||||||
$site_url = $row['site_url'];
|
|
||||||
$feed_url = $row['feed_url'];
|
|
||||||
$title = $row['title'];
|
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
|
|
||||||
feed_url = ? AND owner_uid = ?");
|
|
||||||
$sth->execute([$feed_url, $_SESSION['uid']]);
|
|
||||||
|
|
||||||
if (!$sth->fetch()) {
|
|
||||||
$sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
|
|
||||||
(owner_uid,feed_url,title,cat_id,site_url)
|
|
||||||
VALUES (?, ?, ?, NULL, ?)");
|
|
||||||
|
|
||||||
$sth->execute([$_SESSION['uid'], $feed_url, $title, $site_url]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function catchupFeed() {
|
function catchupFeed() {
|
||||||
$feed_id = clean($_REQUEST['feed_id']);
|
$feed_id = clean($_REQUEST['feed_id']);
|
||||||
$is_cat = clean($_REQUEST['is_cat']) == "true";
|
$is_cat = clean($_REQUEST['is_cat']) == "true";
|
||||||
|
|
|
@ -1379,18 +1379,11 @@ class RSSUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deprecated; table not used
|
||||||
static function expire_feed_archive() {
|
static function expire_feed_archive() {
|
||||||
Debug::log("Removing old archived feeds...");
|
|
||||||
|
|
||||||
$pdo = Db::pdo();
|
$pdo = Db::pdo();
|
||||||
|
|
||||||
if (DB_TYPE == "pgsql") {
|
$pdo->query("DELETE FROM ttrss_archived_feeds");
|
||||||
$pdo->query("DELETE FROM ttrss_archived_feeds
|
|
||||||
WHERE created < NOW() - INTERVAL '1 month'");
|
|
||||||
} else {
|
|
||||||
$pdo->query("DELETE FROM ttrss_archived_feeds
|
|
||||||
WHERE created < DATE_SUB(NOW(), INTERVAL 1 MONTH)");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function expire_lock_files() {
|
static function expire_lock_files() {
|
||||||
|
|
|
@ -175,11 +175,6 @@ const Article = {
|
||||||
|
|
||||||
return comments;
|
return comments;
|
||||||
},
|
},
|
||||||
formatOriginallyFrom: function(hl) {
|
|
||||||
return hl.orig_feed ? `<span>
|
|
||||||
${__('Originally from:')} <a target="_blank" rel="noopener noreferrer" href="${App.escapeHtml(hl.orig_feed[1])}">${hl.orig_feed[0]}</a>
|
|
||||||
</span>` : "";
|
|
||||||
},
|
|
||||||
unpack: function(row) {
|
unpack: function(row) {
|
||||||
if (row.hasAttribute("data-content")) {
|
if (row.hasAttribute("data-content")) {
|
||||||
console.log("unpacking: " + row.id);
|
console.log("unpacking: " + row.id);
|
||||||
|
@ -220,7 +215,6 @@ const Article = {
|
||||||
if (hl) {
|
if (hl) {
|
||||||
|
|
||||||
const comments = this.formatComments(hl);
|
const comments = this.formatComments(hl);
|
||||||
const originally_from = this.formatOriginallyFrom(hl);
|
|
||||||
|
|
||||||
const article = `<div class="post post-${hl.id}" data-article-id="${hl.id}">
|
const article = `<div class="post post-${hl.id}" data-article-id="${hl.id}">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
|
@ -243,7 +237,6 @@ const Article = {
|
||||||
</div>
|
</div>
|
||||||
<div id="POSTNOTE-${hl.id}">${hl.note}</div>
|
<div id="POSTNOTE-${hl.id}">${hl.note}</div>
|
||||||
<div class="content" lang="${hl.lang ? hl.lang : 'en'}">
|
<div class="content" lang="${hl.lang ? hl.lang : 'en'}">
|
||||||
${originally_from}
|
|
||||||
${hl.content}
|
${hl.content}
|
||||||
${hl.enclosures}
|
${hl.enclosures}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -420,7 +420,6 @@ const Headlines = {
|
||||||
row_class += App.getInitParam("cdm_expanded") ? " expanded" : " expandable";
|
row_class += App.getInitParam("cdm_expanded") ? " expanded" : " expandable";
|
||||||
|
|
||||||
const comments = Article.formatComments(hl);
|
const comments = Article.formatComments(hl);
|
||||||
const originally_from = Article.formatOriginallyFrom(hl);
|
|
||||||
|
|
||||||
row = `<div class="cdm ${row_class} ${Article.getScoreClass(hl.score)}"
|
row = `<div class="cdm ${row_class} ${Article.getScoreClass(hl.score)}"
|
||||||
id="RROW-${hl.id}"
|
id="RROW-${hl.id}"
|
||||||
|
@ -483,7 +482,6 @@ const Headlines = {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="right">
|
<div class="right">
|
||||||
${originally_from}
|
|
||||||
${hl.buttons}
|
${hl.buttons}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1085,43 +1083,6 @@ const Headlines = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* not exposed in the UI by default, deprecated - ? */
|
|
||||||
archiveSelection: function () {
|
|
||||||
const rows = Headlines.getSelected();
|
|
||||||
|
|
||||||
if (rows.length == 0) {
|
|
||||||
alert(__("No articles selected."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fn = Feeds.getName(Feeds.getActive(), Feeds.activeIsCat());
|
|
||||||
let str;
|
|
||||||
let op;
|
|
||||||
|
|
||||||
if (Feeds.getActive() != 0) {
|
|
||||||
str = ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows.length);
|
|
||||||
op = "archive";
|
|
||||||
} else {
|
|
||||||
str = ngettext("Move %d archived article back?", "Move %d archived articles back?", rows.length);
|
|
||||||
str += " " + __("Please note that unstarred articles might get purged on next feed update.");
|
|
||||||
|
|
||||||
op = "unarchive";
|
|
||||||
}
|
|
||||||
|
|
||||||
str = str.replace("%d", rows.length);
|
|
||||||
str = str.replace("%s", fn);
|
|
||||||
|
|
||||||
if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = {op: "rpc", method: op, ids: rows.toString()};
|
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
|
||||||
App.handleRpcJson(transport);
|
|
||||||
Feeds.reloadCurrent();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
catchupSelection: function () {
|
catchupSelection: function () {
|
||||||
const rows = Headlines.getSelected();
|
const rows = Headlines.getSelected();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue