diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index e8ebb2c4bb..c31b6dd76f 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -425,8 +425,9 @@ public interface DaoMessage { @Query("SELECT thread, msgid, hash, inreplyto FROM message" + " WHERE account = :account" + " AND (msgid IN (:msgids) OR inreplyto IN (:msgids))" + - " AND (:range IS NULL || received > :range)") - List getThreadInfo(long account, List msgids, Long range); + " AND (:from IS NULL || received > :from)" + + " AND (:to IS NULL || received < :to)") + List getThreadInfo(long account, List msgids, Long from, Long to); @Query("SELECT * FROM message" + " WHERE account = :account" + diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index c31fd5b71a..d3002da5c0 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -141,7 +141,7 @@ public class MessageHelper { static final int DEFAULT_DOWNLOAD_SIZE = 4 * 1024 * 1024; // bytes static final String HEADER_CORRELATION_ID = "X-Correlation-ID"; static final int MAX_SUBJECT_AGE = 48; // hours - static final long MAX_THREAD_AGE = 180; // days + static final long MAX_THREAD_RANGE = 180; // days static final List RECEIVED_WORDS = Collections.unmodifiableList(Arrays.asList( "from", "by", "via", "with", "id", "for" @@ -1484,10 +1484,11 @@ public class MessageHelper { List all = new ArrayList<>(refs); all.add(msgid); - Long range = (received == 0 ? null : received - MAX_THREAD_AGE * 24 * 3600L); + Long start = (received == 0 ? null : received - MAX_THREAD_RANGE * 24 * 3600L); + Long end = (received == 0 ? null : received + MAX_THREAD_RANGE * 24 * 3600L); List infos = (all.size() == 0 ? new ArrayList<>() - : db.message().getThreadInfo(account, all, range)); + : db.message().getThreadInfo(account, all, start, end)); // References, In-Reply-To (sent before) for (TupleThreadInfo info : infos)