Browse Source

update: add option to send digests

Andrew Dolgov 6 months ago
parent
commit
3bd3324e5a
3 changed files with 14 additions and 8 deletions
  1. 7 7
      classes/article.php
  2. 1 1
      classes/rpc.php
  3. 6 0
      update.php

+ 7 - 7
classes/article.php

@@ -697,17 +697,17 @@ class Article extends Handler_Protected {
 
 		$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) {
+				unread = true
+					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
+		} else if ($cmode == 2) {
 			$sth = $pdo->prepare("UPDATE ttrss_user_entries SET
-			unread = true
-				WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
+				unread = NOT unread,last_read = NOW()
+					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
 		} else {
 			$sth = $pdo->prepare("UPDATE ttrss_user_entries SET
-				unread = NOT unread,last_read = NOW()
+				unread = false,last_read = NOW()
 					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
 		}
 

+ 1 - 1
classes/rpc.php

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

+ 6 - 0
update.php

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