diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 07b773f25f..82537e618d 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -2214,6 +2214,7 @@ class Core { : message.references + " " + message.msgid); MimeMessage icopy = new MimeMessageEx((MimeMessage) imessage, msgid); icopy.addHeader("References", MessageHelper.limitReferences(ref)); + icopy.addHeader(MessageHelper.HEADER_MODIFIED_TIME, Long.toString(new Date().getTime())); MessageHelper helper = new MessageHelper(icopy, context); MessageHelper.MessageParts parts = helper.getMessageParts(); List aparts = parts.getAttachmentParts(); @@ -3244,6 +3245,7 @@ class Core { MimeMessage icopy = new MimeMessageEx((MimeMessage) imessage, msgid); icopy.setSubject(subject); // Update or delete subject icopy.addHeader("References", MessageHelper.limitReferences(ref)); + icopy.addHeader(MessageHelper.HEADER_MODIFIED_TIME, Long.toString(new Date().getTime())); ifolder.appendMessages(new Message[]{icopy}); @@ -4643,7 +4645,7 @@ class Core { Long received; long future = new Date().getTime() + FUTURE_RECEIVED; - if (account.use_date || EntityFolder.SENT.equals(folder.type)) { + if (account.use_date || EntityFolder.SENT.equals(folder.type) || helper.isModified()) { received = sent; if (received == null || received == 0 || received > future) received = helper.getReceived(); diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 785ddf5060..4ec37f5c8c 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -180,6 +180,7 @@ public class MessageHelper { static final String HEADER_CORRELATION_ID = "X-Correlation-ID"; static final String HEADER_MICROSOFT_ORIGINAL_MESSAGE_ID = "X-Microsoft-Original-Message-ID"; static final String HEADER_GOOGLE_ORIGINAL_MESSAGE_ID = "X-Google-Original-Message-ID"; + static final String HEADER_MODIFIED_TIME = "X-Modified-Time"; static final int MAX_SUBJECT_AGE = 48; // hours static final int DEFAULT_THREAD_RANGE = 7; // 2^7 = 128 days static final int MAX_UNZIP_COUNT = 20; @@ -3040,6 +3041,11 @@ public class MessageHelper { return (size < 0 ? null : size); } + boolean isModified() throws MessagingException { + ensureHeaders(); + return (imessage.getHeader(HEADER_MODIFIED_TIME) != null); + } + Long getReceived() throws MessagingException { ensureEnvelope();