diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 893f4d6f17..471ba2257b 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -5967,9 +5967,8 @@ public class AdapterMessage extends RecyclerView.Adapter all = new ArrayList<>(); - if (message.inreplyto != null) - for (String inreplyto : message.inreplyto.split(" ")) { - List replied = db.message().getMessagesByMsgId(folder.account, inreplyto); - if (replied != null) - all.addAll(replied); - } + if (message.inreplyto != null) { + List replied = db.message().getMessagesByMsgId(folder.account, message.inreplyto); + if (replied != null) + all.addAll(replied); + } if (r.refid != null) { List refs = db.message().getMessagesByMsgId(folder.account, r.refid); if (refs != null) @@ -4268,8 +4267,7 @@ class Core { } for (EntityFolder f : map.values()) - for (String inreplyto : message.inreplyto.split(" ")) - EntityOperation.queue(context, f, EntityOperation.REPORT, inreplyto, label); + EntityOperation.queue(context, f, EntityOperation.REPORT, message.inreplyto, label); } } } catch (Throwable ex) { diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 483e6b7b13..ae3a64bcdc 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -6458,13 +6458,12 @@ public class FragmentCompose extends FragmentBase { if (extras.getBoolean("archive")) { EntityFolder archive = db.folder().getFolderByType(draft.account, EntityFolder.ARCHIVE); - if (archive != null) - for (String inreplyto : draft.inreplyto.split(" ")) { - List messages = db.message().getMessagesByMsgId(draft.account, inreplyto); - if (messages != null) - for (EntityMessage message : messages) - EntityOperation.queue(context, message, EntityOperation.MOVE, archive.id); - } + if (archive != null) { + List messages = db.message().getMessagesByMsgId(draft.account, draft.inreplyto); + if (messages != null) + for (EntityMessage message : messages) + EntityOperation.queue(context, message, EntityOperation.MOVE, archive.id); + } } } } @@ -7952,15 +7951,18 @@ public class FragmentCompose extends FragmentBase { return false; } - for (String inreplyto : draft.inreplyto.split(" ")) { - List messages = db.message().getMessagesByMsgId(draft.account, inreplyto); - for (EntityMessage message : messages) { - EntityFolder folder = db.folder().getFolder(message.folder); - if (folder == null) - continue; - if (EntityFolder.INBOX.equals(folder.type) || EntityFolder.USER.equals(folder.type)) - return true; - } + List messages = db.message().getMessagesByMsgId(draft.account, draft.inreplyto); + if (messages == null || messages.size() == 0) { + args.putString("reason", "In-reply-to gone"); + return false; + } + + for (EntityMessage message : messages) { + EntityFolder folder = db.folder().getFolder(message.folder); + if (folder == null) + continue; + if (EntityFolder.INBOX.equals(folder.type) || EntityFolder.USER.equals(folder.type)) + return true; } args.putString("reason", "Not in inbox or unread"); diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index f62be17c4c..45c5d6eedf 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -1316,7 +1316,7 @@ public class MessageHelper { String getInReplyTo() throws MessagingException { String[] a = getInReplyTos(); - return (a.length == 0 ? null : TextUtils.join(" ", a)); + return (a.length < 1 ? null : a[0]); } String[] getInReplyTos() throws MessagingException { diff --git a/app/src/main/java/eu/faircode/email/ServiceSend.java b/app/src/main/java/eu/faircode/email/ServiceSend.java index 4875c781e7..8d1662e1a9 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSend.java +++ b/app/src/main/java/eu/faircode/email/ServiceSend.java @@ -566,24 +566,21 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar Long sid = null; EntityFolder sent = null; - if (reply_move && !TextUtils.isEmpty(message.inreplyto)) - for (String inreplyto : message.inreplyto.split(" ")) { - List replied = db.message().getMessagesByMsgId(message.account, inreplyto); - if (replied != null) - for (EntityMessage m : replied) - if (!m.ui_hide) { - EntityFolder folder = db.folder().getFolder(m.folder); - if (folder != null && - (EntityFolder.INBOX.equals(folder.type) || - EntityFolder.ARCHIVE.equals(folder.type) || - EntityFolder.USER.equals(folder.type))) { - sent = folder; - break; - } + if (reply_move && !TextUtils.isEmpty(message.inreplyto)) { + List replied = db.message().getMessagesByMsgId(message.account, message.inreplyto); + if (replied != null) + for (EntityMessage m : replied) + if (!m.ui_hide) { + EntityFolder folder = db.folder().getFolder(m.folder); + if (folder != null && + (EntityFolder.INBOX.equals(folder.type) || + EntityFolder.ARCHIVE.equals(folder.type) || + EntityFolder.USER.equals(folder.type))) { + sent = folder; + break; } - if (sent != null) - break; - } + } + } if (sent == null) sent = db.folder().getFolderByType(message.account, EntityFolder.SENT); @@ -808,12 +805,11 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar } // Mark replied - if (message.inreplyto != null) - for (String inreplyto : message.inreplyto.split(" ")) { - List replieds = db.message().getMessagesByMsgId(message.account, inreplyto); - for (EntityMessage replied : replieds) - EntityOperation.queue(this, replied, EntityOperation.ANSWERED, true); - } + if (message.inreplyto != null) { + List replieds = db.message().getMessagesByMsgId(message.account, message.inreplyto); + for (EntityMessage replied : replieds) + EntityOperation.queue(this, replied, EntityOperation.ANSWERED, true); + } // Mark forwarded if (message.wasforwardedfrom != null) {