mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Use extra header to find messages again
This commit is contained in:
parent
f97328f725
commit
7048bf0e56
3 changed files with 12 additions and 6 deletions
|
@ -170,10 +170,9 @@ public interface DaoMessage {
|
|||
@Query("SELECT message.* FROM message" +
|
||||
" JOIN folder ON folder.id = message.folder" +
|
||||
" WHERE message.account = :account" +
|
||||
" AND (message.msgid = :msgid" +
|
||||
" OR message.msgid = :reference)" +
|
||||
" AND message.msgid = :msgid" +
|
||||
" AND ui_found = :found")
|
||||
List<EntityMessage> getMessageByMsgId(long account, String msgid, String reference, boolean found);
|
||||
List<EntityMessage> getMessageByMsgId(long account, String msgid, boolean found);
|
||||
|
||||
@Query("SELECT * FROM message" +
|
||||
" WHERE folder = :folder" +
|
||||
|
|
|
@ -187,6 +187,7 @@ public class MessageHelper {
|
|||
imessage.addHeader("References", (replying.references == null ? "" : replying.references + " ") + replying.msgid);
|
||||
}
|
||||
|
||||
imessage.addHeader("X-FairEmail-ID", message.msgid);
|
||||
imessage.addHeader("X-FairEmail-Thread", message.thread);
|
||||
|
||||
imessage.setFlag(Flags.Flag.SEEN, message.seen);
|
||||
|
@ -368,6 +369,11 @@ public class MessageHelper {
|
|||
}
|
||||
|
||||
String getMessageID() throws MessagingException {
|
||||
// Outlook outbox -> sent
|
||||
String[] xID = imessage.getHeader("X-FairEmail-ID");
|
||||
if (xID != null && xID.length > 0)
|
||||
return xID[0];
|
||||
|
||||
return imessage.getHeader("Message-ID", null);
|
||||
}
|
||||
|
||||
|
@ -385,6 +391,7 @@ public class MessageHelper {
|
|||
}
|
||||
|
||||
String getThreadId(long uid) throws MessagingException {
|
||||
// Some providers break references when moving messages
|
||||
String[] xThread = imessage.getHeader("X-FairEmail-Thread");
|
||||
if (xThread != null && xThread.length > 0)
|
||||
return xThread[0];
|
||||
|
@ -392,6 +399,7 @@ public class MessageHelper {
|
|||
for (String ref : getReferences())
|
||||
if (!TextUtils.isEmpty(ref))
|
||||
return ref;
|
||||
|
||||
String msgid = getMessageID();
|
||||
return (TextUtils.isEmpty(msgid) ? Long.toString(uid) : msgid);
|
||||
}
|
||||
|
|
|
@ -2021,9 +2021,8 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
// Will fetch headers within database transaction
|
||||
String msgid = helper.getMessageID();
|
||||
String[] refs = helper.getReferences();
|
||||
String reference = (refs.length == 1 && refs[0].indexOf(BuildConfig.APPLICATION_ID) > 0 ? refs[0] : msgid);
|
||||
Log.i(Helper.TAG, "Searching for " + msgid + " / " + reference);
|
||||
for (EntityMessage dup : db.message().getMessageByMsgId(folder.account, msgid, reference, found)) {
|
||||
Log.i(Helper.TAG, "Searching for " + msgid);
|
||||
for (EntityMessage dup : db.message().getMessageByMsgId(folder.account, msgid, found)) {
|
||||
EntityFolder dfolder = db.folder().getFolder(dup.folder);
|
||||
boolean outbox = EntityFolder.OUTBOX.equals(dfolder.type);
|
||||
Log.i(Helper.TAG, folder.name + " found as id=" + dup.id + "/" + dup.uid +
|
||||
|
|
Loading…
Reference in a new issue