Browse Source

Fixed handling known messages

Fixes #41
main
M66B 6 years ago
parent
commit
76557a7345
2 changed files with 12 additions and 13 deletions
  1. +1
    -1
      app/src/main/java/eu/faircode/email/DaoMessage.java
  2. +11
    -12
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java

+ 1
- 1
app/src/main/java/eu/faircode/email/DaoMessage.java View File

@ -85,7 +85,7 @@ public interface DaoMessage {
" WHERE msgid = :msgid" +
" AND folder.type <> '" + EntityFolder.INBOX + "'" +
" AND folder.type <> '" + EntityFolder.ARCHIVE + "'")
EntityMessage getMessageByMsgId(String msgid);
List<EntityMessage> getMessageByMsgId(String msgid);
@Query("SELECT message.* FROM message" +
" JOIN folder ON folder.id = message.folder" +


+ 11
- 12
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -1222,19 +1222,18 @@ public class ServiceSynchronize extends LifecycleService {
if (message == null) {
// Will fetch headers within database transaction
String msgid = helper.getMessageID();
message = db.message().getMessageByMsgId(msgid);
if (message != null) {
EntityFolder mfolder = db.folder().getFolder(message.folder);
Log.i(Helper.TAG, folder.name + " found as id=" + message.id +
" folder=" + mfolder.type + ":" + message.folder + "/" + folder.type + ":" + folder.id);
if (message.folder.equals(folder.id) || EntityFolder.OUTBOX.equals(mfolder.type)) {
Log.i(Helper.TAG, folder.name + " found as id=" + message.id + " uid=" + message.uid + " msgid=" + msgid);
message.folder = folder.id;
message.uid = uid;
db.message().updateMessage(message);
for (EntityMessage dup : db.message().getMessageByMsgId(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);
if (dup.folder.equals(folder.id) || EntityFolder.OUTBOX.equals(dfolder.type)) {
Log.i(Helper.TAG, folder.name + " found as id=" + dup.id + " uid=" + dup.uid + " msgid=" + msgid);
dup.folder = folder.id;
dup.uid = uid;
db.message().updateMessage(dup);
message = dup;
result = -1;
} else
message = null;
}
}
}


Loading…
Cancel
Save