Added upper limit to thread search

pull/207/head
M66B 3 years ago
parent fba2ab9870
commit 24edf5f9d5

@ -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<TupleThreadInfo> getThreadInfo(long account, List<String> msgids, Long range);
" AND (:from IS NULL || received > :from)" +
" AND (:to IS NULL || received < :to)")
List<TupleThreadInfo> getThreadInfo(long account, List<String> msgids, Long from, Long to);
@Query("SELECT * FROM message" +
" WHERE account = :account" +

@ -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<String> RECEIVED_WORDS = Collections.unmodifiableList(Arrays.asList(
"from", "by", "via", "with", "id", "for"
@ -1484,10 +1484,11 @@ public class MessageHelper {
List<String> 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<TupleThreadInfo> 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)

Loading…
Cancel
Save