1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-28 10:47:28 +00:00

Improved late draft logic

This commit is contained in:
M66B 2022-08-30 18:42:22 +02:00
parent 2b813ad2ce
commit 20047afc41

View file

@ -4055,15 +4055,26 @@ class Core {
message = dup;
process = true;
} else if (dup.uid < uid && EntityFolder.DRAFTS.equals(folder.type)) {
} else if (msgid != null && EntityFolder.DRAFTS.equals(folder.type)) {
try {
Message existing = ifolder.getMessageByUID(dup.uid);
Log.e(folder.name + " late draft host=" + account.host +
" uid=" + dup.uid + "<" + uid + " found=" + (existing != null));
if (existing != null) {
existing.setFlag(Flags.Flag.DELETED, true);
expunge(context, ifolder, Arrays.asList(existing));
db.message().setMessageUiHide(dup.id, true);
if (dup.uid < uid) {
MimeMessage existing = (MimeMessage) ifolder.getMessageByUID(dup.uid);
if (existing != null &&
msgid.equals(existing.getHeader(MessageHelper.HEADER_CORRELATION_ID, null))) {
Log.e(folder.name + " late draft" +
" host=" + account.host + " uid=" + dup.uid + "<" + uid);
existing.setFlag(Flags.Flag.DELETED, true);
expunge(context, ifolder, Arrays.asList(existing));
db.message().setMessageUiHide(dup.id, true);
}
} else if (dup.uid > uid) {
if (msgid.equals(imessage.getHeader(MessageHelper.HEADER_CORRELATION_ID, null))) {
Log.e(folder.name + " late draft" +
" host=" + account.host + " uid=" + dup.uid + ">" + uid);
imessage.setFlag(Flags.Flag.DELETED, true);
expunge(context, ifolder, Arrays.asList(imessage));
return null;
}
}
} catch (Throwable ex) {
Log.e(ex);