update: add option to send digests

This commit is contained in:
Andrew Dolgov 2019-03-21 07:44:39 +03:00
parent 6ae0a3dd3e
commit 3bd3324e5a
3 changed files with 15 additions and 9 deletions

View File

@ -697,18 +697,18 @@ class Article extends Handler_Protected {
$ids_qmarks = arr_qmarks($ids); $ids_qmarks = arr_qmarks($ids);
if ($cmode == 0) { if ($cmode == 1) {
$sth = $pdo->prepare("UPDATE ttrss_user_entries SET
unread = false,last_read = NOW()
WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
} else if ($cmode == 1) {
$sth = $pdo->prepare("UPDATE ttrss_user_entries SET $sth = $pdo->prepare("UPDATE ttrss_user_entries SET
unread = true unread = true
WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
} else { } else if ($cmode == 2) {
$sth = $pdo->prepare("UPDATE ttrss_user_entries SET $sth = $pdo->prepare("UPDATE ttrss_user_entries SET
unread = NOT unread,last_read = NOW() unread = NOT unread,last_read = NOW()
WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
} else {
$sth = $pdo->prepare("UPDATE ttrss_user_entries SET
unread = false,last_read = NOW()
WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
} }
$sth->execute(array_merge($ids, [$owner_uid])); $sth->execute(array_merge($ids, [$owner_uid]));

View File

@ -287,7 +287,7 @@ class RPC extends Handler_Protected {
/* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
function catchupSelected() { function catchupSelected() {
$ids = explode(",", clean($_REQUEST["ids"])); $ids = explode(",", clean($_REQUEST["ids"]));
$cmode = sprintf("%d", clean($_REQUEST["cmode"])); $cmode = (int)clean($_REQUEST["cmode"]);
Article::catchupArticlesById($ids, $cmode); Article::catchupArticlesById($ids, $cmode);

View File

@ -24,6 +24,7 @@
$longopts = array("feeds", $longopts = array("feeds",
"daemon", "daemon",
"daemon-loop", "daemon-loop",
"send-digests",
"task:", "task:",
"cleanup-tags", "cleanup-tags",
"quiet", "quiet",
@ -87,6 +88,7 @@
print " --update-schema - update database schema\n"; print " --update-schema - update database schema\n";
print " --gen-search-idx - generate basic PostgreSQL fulltext search index\n"; print " --gen-search-idx - generate basic PostgreSQL fulltext search index\n";
print " --convert-filters - convert type1 filters to type2\n"; print " --convert-filters - convert type1 filters to type2\n";
print " --send-digests - send pending email digests\n";
print " --force-update - force update of all feeds\n"; print " --force-update - force update of all feeds\n";
print " --list-plugins - list all available plugins\n"; print " --list-plugins - list all available plugins\n";
print " --debug-feed N - perform debug update of feed N\n"; print " --debug-feed N - perform debug update of feed N\n";
@ -432,6 +434,10 @@
exit($rc); exit($rc);
} }
if (isset($options["send-digests"])) {
Digest::send_headlines_digests();
}
PluginHost::getInstance()->run_commands($options); PluginHost::getInstance()->run_commands($options);
if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) if (file_exists(LOCK_DIRECTORY . "/$lock_filename"))