diff --git a/functions.php b/functions.php index 84d045d85..a32358997 100644 --- a/functions.php +++ b/functions.php @@ -3189,12 +3189,16 @@ WHERE email != '' AND (last_digest_sent IS NULL OR $interval_query)"); while ($line = db_fetch_assoc($result)) { + if (get_pref($link, 'DIGEST_ENABLE', $line['id'], false)) { print "Sending digest for UID:" . $line['id'] . " - " . $line["email"] . " ... "; + $do_catchup = get_pref($link, 'DIGEST_CATCHUP', $line['id'], false); + $tuple = prepare_headlines_digest($link, $line["id"], $days, $limit); $digest = $tuple[0]; $headlines_count = $tuple[1]; + $affected_ids = $tuple[2]; if ($headlines_count > 0) { @@ -3235,6 +3239,11 @@ print "RC=$rc\n"; + if ($rc) { + print "Marking affected articles as read...\n"; + catchupArticlesById($link, $affected_ids, 0); + } + db_query($link, "UPDATE ttrss_users SET last_digest_sent = NOW() WHERE id = " . $line["id"]); } else { @@ -3251,6 +3260,8 @@ $tmp = __("New headlines for last 24 hours, as of ") . date("Y/m/d H:m") . "\n"; $tmp .= "=======================================================\n\n"; + $affected_ids = array(); + if (DB_TYPE == "pgsql") { $interval_query = "ttrss_entries.date_entered > NOW() - INTERVAL '$days days'"; } else if (DB_TYPE == "mysql") { @@ -3260,6 +3271,7 @@ $result = db_query($link, "SELECT ttrss_entries.title, ttrss_feeds.title AS feed_title, date_entered, + ttrss_user_entries.ref_id, link, SUBSTRING(last_updated,1,19) AS last_updated FROM @@ -3278,6 +3290,9 @@ $headlines_count = db_num_rows($result); while ($line = db_fetch_assoc($result)) { + + array_push($affected_ids, $line["ref_id"]); + $updated = smart_date_time(strtotime($line["last_updated"])); $feed_title = $line["feed_title"]; @@ -3298,7 +3313,7 @@ __("To unsubscribe, visit your configuration options or contact instance owner.\n"); - return array($tmp, $headlines_count); + return array($tmp, $headlines_count, $affected_ids); } function check_for_update($link, $brief_fmt = true) { diff --git a/sanity_check.php b/sanity_check.php index b62e5c0a8..04f717ff9 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -2,7 +2,7 @@ require_once "functions.php"; define('EXPECTED_CONFIG_VERSION', 9); - define('SCHEMA_VERSION', 22); + define('SCHEMA_VERSION', 23); if (!file_exists("config.php")) { print __("Fatal Error: You forgot to copy diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index 5db0814f2..a340dbf25 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -199,7 +199,7 @@ create table ttrss_tags (id integer primary key auto_increment, create table ttrss_version (schema_version int not null) TYPE=InnoDB; -insert into ttrss_version values (22); +insert into ttrss_version values (23); create table ttrss_prefs_types (id integer not null primary key, type_name varchar(100) not null) TYPE=InnoDB; @@ -299,6 +299,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('FRESH_ARTICLE_MAX_AGE', 3, '24', 'Maximum age of fresh articles (in hours)',2); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DIGEST_CATCHUP', 1, 'false', 'Mark articles in e-mail digest as read',1); + create table ttrss_user_prefs ( owner_uid integer not null, pref_name varchar(250), diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index 73403eb82..c7e0f8fbf 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -178,7 +178,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid); create table ttrss_version (schema_version int not null); -insert into ttrss_version values (22); +insert into ttrss_version values (23); create table ttrss_prefs_types (id integer not null primary key, type_name varchar(100) not null); @@ -274,6 +274,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('FRESH_ARTICLE_MAX_AGE', 3, '24', 'Maximum age of fresh articles (in hours)',2); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DIGEST_CATCHUP', 1, 'false', 'Mark articles in e-mail digest as read',1); + create table ttrss_user_prefs ( owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE, pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE, diff --git a/schema/versions/mysql/23.sql b/schema/versions/mysql/23.sql new file mode 100644 index 000000000..fe54e757d --- /dev/null +++ b/schema/versions/mysql/23.sql @@ -0,0 +1,3 @@ +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DIGEST_CATCHUP', 1, 'false', 'Mark articles in e-mail digest as read',1); + +update ttrss_version set schema_version = 23; diff --git a/schema/versions/pgsql/23.sql b/schema/versions/pgsql/23.sql new file mode 100644 index 000000000..fe54e757d --- /dev/null +++ b/schema/versions/pgsql/23.sql @@ -0,0 +1,3 @@ +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DIGEST_CATCHUP', 1, 'false', 'Mark articles in e-mail digest as read',1); + +update ttrss_version set schema_version = 23;