mirror of https://github.com/M66B/FairEmail.git
Limit thread search range
This commit is contained in:
parent
88d4b5cf66
commit
e5ec014a6a
|
@ -2909,7 +2909,7 @@ class Core {
|
|||
message.references = TextUtils.join(" ", helper.getReferences());
|
||||
message.inreplyto = helper.getInReplyTo();
|
||||
message.deliveredto = helper.getDeliveredTo();
|
||||
message.thread = helper.getThreadId(context, account.id, folder.id, 0);
|
||||
message.thread = helper.getThreadId(context, account.id, folder.id, 0, received);
|
||||
message.priority = helper.getPriority();
|
||||
message.sensitivity = helper.getSensitivity();
|
||||
message.auto_submitted = helper.getAutoSubmitted();
|
||||
|
@ -3807,7 +3807,7 @@ class Core {
|
|||
have = true;
|
||||
|
||||
if (dup.folder.equals(folder.id)) {
|
||||
String thread = helper.getThreadId(context, account.id, folder.id, uid);
|
||||
String thread = helper.getThreadId(context, account.id, folder.id, uid, dup.received);
|
||||
Log.i(folder.name + " found as id=" + dup.id +
|
||||
" uid=" + dup.uid + "/" + uid +
|
||||
" msgid=" + msgid + " thread=" + thread);
|
||||
|
@ -3886,7 +3886,7 @@ class Core {
|
|||
message.inreplyto = helper.getInReplyTo();
|
||||
// Local address contains control or whitespace in string ``mailing list someone@example.org''
|
||||
message.deliveredto = helper.getDeliveredTo();
|
||||
message.thread = helper.getThreadId(context, account.id, folder.id, uid);
|
||||
message.thread = helper.getThreadId(context, account.id, folder.id, uid, received);
|
||||
if (BuildConfig.DEBUG && message.thread.startsWith("outlook:"))
|
||||
message.warning = message.thread;
|
||||
message.priority = helper.getPriority();
|
||||
|
|
|
@ -424,8 +424,9 @@ public interface DaoMessage {
|
|||
|
||||
@Query("SELECT thread, msgid, hash, inreplyto FROM message" +
|
||||
" WHERE account = :account" +
|
||||
" AND (msgid IN (:msgids) OR inreplyto IN (:msgids))")
|
||||
List<TupleThreadInfo> getThreadInfo(long account, List<String> msgids);
|
||||
" AND (msgid IN (:msgids) OR inreplyto IN (:msgids))" +
|
||||
" AND (:range IS NULL || received > :range)")
|
||||
List<TupleThreadInfo> getThreadInfo(long account, List<String> msgids, Long range);
|
||||
|
||||
@Query("SELECT * FROM message" +
|
||||
" WHERE account = :account" +
|
||||
|
|
|
@ -141,6 +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 List<String> RECEIVED_WORDS = Collections.unmodifiableList(Arrays.asList(
|
||||
"from", "by", "via", "with", "id", "for"
|
||||
|
@ -1334,10 +1335,10 @@ public class MessageHelper {
|
|||
return reportHeaders;
|
||||
}
|
||||
|
||||
String getThreadId(Context context, long account, long folder, long uid) throws MessagingException {
|
||||
String getThreadId(Context context, long account, long folder, long uid, long received) throws MessagingException {
|
||||
if (threadId == null)
|
||||
if (true)
|
||||
threadId = _getThreadIdAlt(context, account, folder, uid);
|
||||
threadId = _getThreadIdAlt(context, account, folder, uid, received);
|
||||
else
|
||||
threadId = _getThreadId(context, account, folder, uid);
|
||||
return threadId;
|
||||
|
@ -1429,7 +1430,7 @@ public class MessageHelper {
|
|||
return thread;
|
||||
}
|
||||
|
||||
private String _getThreadIdAlt(Context context, long account, long folder, long uid) throws MessagingException {
|
||||
private String _getThreadIdAlt(Context context, long account, long folder, long uid, long received) throws MessagingException {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
if (imessage instanceof GmailMessage) {
|
||||
|
@ -1483,9 +1484,10 @@ public class MessageHelper {
|
|||
|
||||
List<String> all = new ArrayList<>(refs);
|
||||
all.add(msgid);
|
||||
Long range = (received == 0 ? null : received - MAX_THREAD_AGE * 24 * 3600L);
|
||||
List<TupleThreadInfo> infos = (all.size() == 0
|
||||
? new ArrayList<>()
|
||||
: db.message().getThreadInfo(account, all));
|
||||
: db.message().getThreadInfo(account, all, range));
|
||||
|
||||
// References, In-Reply-To (sent before)
|
||||
for (TupleThreadInfo info : infos)
|
||||
|
|
Loading…
Reference in New Issue