mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-06 00:53:26 +02:00
Prevent messages with same message ID from being grouped
This commit is contained in:
@@ -298,6 +298,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
private boolean language_detection;
|
||||
private List<String> languages;
|
||||
private static boolean debug;
|
||||
private int level;
|
||||
|
||||
private boolean gotoTop = false;
|
||||
private Integer gotoPos = null;
|
||||
@@ -1399,6 +1400,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
tvError.setText(text);
|
||||
tvError.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (BuildConfig.DEBUG && level <= android.util.Log.INFO)
|
||||
error = message.thread;
|
||||
tvError.setText(error);
|
||||
tvError.setVisibility(error == null ? View.GONE : View.VISIBLE);
|
||||
ibHelp.setVisibility(error == null ? View.GONE : View.VISIBLE);
|
||||
@@ -6154,6 +6157,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
languages = null;
|
||||
|
||||
debug = prefs.getBoolean("debug", false);
|
||||
level = prefs.getInt("log_level", Log.getDefaultLogLevel());
|
||||
|
||||
DiffUtil.ItemCallback<TupleMessageEx> callback = new DiffUtil.ItemCallback<TupleMessageEx>() {
|
||||
@Override
|
||||
|
||||
@@ -2729,7 +2729,7 @@ class Core {
|
||||
message.references = TextUtils.join(" ", helper.getReferences());
|
||||
message.inreplyto = helper.getInReplyTo();
|
||||
message.deliveredto = helper.getDeliveredTo();
|
||||
message.thread = helper.getThreadId(context, account.id, 0);
|
||||
message.thread = helper.getThreadId(context, account.id, folder.id, 0);
|
||||
message.priority = helper.getPriority();
|
||||
message.auto_submitted = helper.getAutoSubmitted();
|
||||
message.receipt_request = helper.getReceiptRequested();
|
||||
@@ -3615,7 +3615,7 @@ class Core {
|
||||
have = true;
|
||||
|
||||
if (dup.folder.equals(folder.id)) {
|
||||
String thread = helper.getThreadId(context, account.id, uid);
|
||||
String thread = helper.getThreadId(context, account.id, folder.id, uid);
|
||||
Log.i(folder.name + " found as id=" + dup.id +
|
||||
" uid=" + dup.uid + "/" + uid +
|
||||
" msgid=" + msgid + " thread=" + thread);
|
||||
@@ -3701,7 +3701,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, uid);
|
||||
message.thread = helper.getThreadId(context, account.id, folder.id, uid);
|
||||
message.priority = helper.getPriority();
|
||||
message.auto_submitted = helper.getAutoSubmitted();
|
||||
message.receipt_request = helper.getReceiptRequested();
|
||||
|
||||
@@ -144,7 +144,7 @@ public class FragmentOptions extends FragmentBase {
|
||||
"swipe_reply",
|
||||
"language_detection",
|
||||
"quick_filter", "quick_scroll",
|
||||
"experiments", "debug",
|
||||
"experiments", "debug", "log_level",
|
||||
"biometrics",
|
||||
"default_light"
|
||||
};
|
||||
|
||||
@@ -1135,7 +1135,7 @@ public class MessageHelper {
|
||||
return (header == null ? null : MimeUtility.unfold(header));
|
||||
}
|
||||
|
||||
String getThreadId(Context context, long account, long uid) throws MessagingException {
|
||||
String getThreadId(Context context, long account, long folder, long uid) throws MessagingException {
|
||||
if (imessage instanceof GmailMessage) {
|
||||
// https://developers.google.com/gmail/imap/imap-extensions#access_to_the_gmail_thread_id_x-gm-thrid
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
@@ -1173,23 +1173,24 @@ public class MessageHelper {
|
||||
}
|
||||
}
|
||||
|
||||
if (thread == null && refs.size() > 0)
|
||||
thread = refs.get(0);
|
||||
|
||||
if (thread != null) {
|
||||
List<EntityMessage> after = db.message().getMessagesByInReplyTo(account, msgid);
|
||||
for (EntityMessage message : after)
|
||||
if (!TextUtils.isEmpty(message.thread) && !thread.equals(message.thread)) {
|
||||
Log.w("Updating after thread from " + message.thread + " to " + thread);
|
||||
db.message().updateMessageThread(message.account, message.thread, thread);
|
||||
if (thread == null) {
|
||||
List<EntityMessage> similar = db.message().getMessagesByMsgId(account, msgid);
|
||||
for (EntityMessage message : similar)
|
||||
if (!TextUtils.isEmpty(message.thread) && message.folder != folder) {
|
||||
thread = message.thread;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (thread == null)
|
||||
if (TextUtils.isEmpty(msgid))
|
||||
thread = Long.toString(uid);
|
||||
else
|
||||
thread = msgid;
|
||||
thread = (uid == 0 /* POP3 */ ? msgid : account + ":" + folder + ":" + uid);
|
||||
|
||||
List<EntityMessage> after = db.message().getMessagesByInReplyTo(account, msgid);
|
||||
for (EntityMessage message : after)
|
||||
if (!TextUtils.isEmpty(message.thread) && !thread.equals(message.thread)) {
|
||||
Log.w("Updating after thread from " + message.thread + " to " + thread);
|
||||
db.message().updateMessageThread(message.account, message.thread, thread);
|
||||
}
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user