Added upper limit to thread search

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

@ -425,8 +425,9 @@ public interface DaoMessage {
@Query("SELECT thread, msgid, hash, inreplyto FROM message" + @Query("SELECT thread, msgid, hash, inreplyto FROM message" +
" WHERE account = :account" + " WHERE account = :account" +
" AND (msgid IN (:msgids) OR inreplyto IN (:msgids))" + " AND (msgid IN (:msgids) OR inreplyto IN (:msgids))" +
" AND (:range IS NULL || received > :range)") " AND (:from IS NULL || received > :from)" +
List<TupleThreadInfo> getThreadInfo(long account, List<String> msgids, Long range); " AND (:to IS NULL || received < :to)")
List<TupleThreadInfo> getThreadInfo(long account, List<String> msgids, Long from, Long to);
@Query("SELECT * FROM message" + @Query("SELECT * FROM message" +
" WHERE account = :account" + " WHERE account = :account" +

@ -141,7 +141,7 @@ public class MessageHelper {
static final int DEFAULT_DOWNLOAD_SIZE = 4 * 1024 * 1024; // bytes static final int DEFAULT_DOWNLOAD_SIZE = 4 * 1024 * 1024; // bytes
static final String HEADER_CORRELATION_ID = "X-Correlation-ID"; static final String HEADER_CORRELATION_ID = "X-Correlation-ID";
static final int MAX_SUBJECT_AGE = 48; // hours 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( static final List<String> RECEIVED_WORDS = Collections.unmodifiableList(Arrays.asList(
"from", "by", "via", "with", "id", "for" "from", "by", "via", "with", "id", "for"
@ -1484,10 +1484,11 @@ public class MessageHelper {
List<String> all = new ArrayList<>(refs); List<String> all = new ArrayList<>(refs);
all.add(msgid); 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 List<TupleThreadInfo> infos = (all.size() == 0
? new ArrayList<>() ? new ArrayList<>()
: db.message().getThreadInfo(account, all, range)); : db.message().getThreadInfo(account, all, start, end));
// References, In-Reply-To (sent before) // References, In-Reply-To (sent before)
for (TupleThreadInfo info : infos) for (TupleThreadInfo info : infos)

Loading…
Cancel
Save