diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 2f81ce20..9a57787e 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -82,10 +82,11 @@ public interface DaoMessage { @Query("SELECT message.* FROM message" + " JOIN folder ON folder.id = message.folder" + - " WHERE msgid = :msgid" + + " WHERE message.account = :account" + + " AND message.msgid = :msgid" + " AND folder.type <> '" + EntityFolder.INBOX + "'" + " AND folder.type <> '" + EntityFolder.ARCHIVE + "'") - List getMessageByMsgId(String msgid); + List getMessageByMsgId(long account, String msgid); @Query("SELECT message.* FROM message" + " JOIN folder ON folder.id = message.folder" + diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index d7ab32be..18940b6c 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1225,7 +1225,7 @@ public class ServiceSynchronize extends LifecycleService { if (message == null) { // Will fetch headers within database transaction String msgid = helper.getMessageID(); - for (EntityMessage dup : db.message().getMessageByMsgId(msgid)) { + for (EntityMessage dup : db.message().getMessageByMsgId(folder.account, msgid)) { EntityFolder dfolder = db.folder().getFolder(dup.folder); Log.i(Helper.TAG, folder.name + " found as id=" + dup.id + " folder=" + dfolder.type + ":" + dup.folder + "/" + folder.type + ":" + folder.id);