X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=classes%2Fdigest.php;h=a61b6dfcaf75256fc6d278d9cede40c2a299937b;hb=c10a43069ec1e71b6608574a81fb29c76919e132;hp=83f39a865aee09e2582f26ef05518213e8645e4f;hpb=f70d456a5bc509e56991195a2f003cf2714d0e13;p=tt-rss.git diff --git a/classes/digest.php b/classes/digest.php index 83f39a86..a61b6dfc 100644 --- a/classes/digest.php +++ b/classes/digest.php @@ -9,14 +9,12 @@ class Digest * @param integer $limit The maximum number of articles by digest. * @return boolean Return false if digests are not enabled. */ - static function send_headlines_digests($debug = false) { - - require_once 'classes/ttrssmailer.php'; + static function send_headlines_digests() { $user_limit = 15; // amount of users to process (e.g. emails to send out) $limit = 1000; // maximum amount of headlines to include - if ($debug) _debug("Sending digests, batch of max $user_limit users, headline limit = $limit"); + Debug::log("Sending digests, batch of max $user_limit users, headline limit = $limit"); if (DB_TYPE == "pgsql") { $interval_qpart = "last_digest_sent < NOW() - INTERVAL '1 days'"; @@ -39,7 +37,7 @@ class Digest time() - $preferred_ts <= 7200 ) { - if ($debug) _debug("Sending digest for UID:" . $line['id'] . " - " . $line["email"]); + Debug::log("Sending digest for UID:" . $line['id'] . " - " . $line["email"]); $do_catchup = get_pref('DIGEST_CATCHUP', $line['id'], false); @@ -56,20 +54,26 @@ class Digest if ($headlines_count > 0) { - $mail = new ttrssMailer(); + $mailer = new Mailer(); + + //$rc = $mail->quickMail($line["email"], $line["login"], DIGEST_SUBJECT, $digest, $digest_text); - $rc = $mail->quickMail($line["email"], $line["login"], DIGEST_SUBJECT, $digest, $digest_text); + $rc = $mailer->mail(["to_name" => $line["login"], + "to_address" => $line["email"], + "subject" => DIGEST_SUBJECT, + "message" => $digest_text, + "message_html" => $digest]); - if (!$rc && $debug) _debug("ERROR: " . $mail->ErrorInfo); + //if (!$rc && $debug) Debug::log("ERROR: " . $mailer->lastError()); - if ($debug) _debug("RC=$rc"); + Debug::log("RC=$rc"); if ($rc && $do_catchup) { - if ($debug) _debug("Marking affected articles as read..."); + Debug::log("Marking affected articles as read..."); Article::catchupArticlesById($affected_ids, 0, $line["id"]); } } else { - if ($debug) _debug("No headlines"); + Debug::log("No headlines"); } $sth = $pdo->prepare("UPDATE ttrss_users SET last_digest_sent = NOW() @@ -80,7 +84,7 @@ class Digest } } - if ($debug) _debug("All done."); + Debug::log("All done."); } @@ -132,12 +136,14 @@ class Digest ref_id = ttrss_entries.id AND feed_id = ttrss_feeds.id AND include_in_digest = true AND $interval_qpart - AND ttrss_user_entries.owner_uid = ? + AND ttrss_user_entries.owner_uid = :user_id AND unread = true AND score >= 0 ORDER BY ttrss_feed_categories.title, ttrss_feeds.title, score DESC, date_updated DESC - LIMIT ?"); - $sth->execute([$user_id, $limit]); + LIMIT :limit"); + $sth->bindParam(':user_id', intval($user_id, 10), \PDO::PARAM_INT); + $sth->bindParam(':limit', intval($limit, 10), \PDO::PARAM_INT); + $sth->execute(); $headlines_count = 0; $headlines = array(); @@ -196,4 +202,4 @@ class Digest return array($tmp, $headlines_count, $affected_ids, $tmp_t); } -} \ No newline at end of file +}