From e2e948d10401698a8f323c506ac7067ffc509690 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 29 Sep 2019 11:43:00 +0200 Subject: [PATCH] Get flags from original message --- app/src/main/java/eu/faircode/email/Core.java | 4 ++-- .../java/eu/faircode/email/MimeMessageEx.java | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 71e7494624..1102bbd32d 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1923,7 +1923,7 @@ class Core { Log.w(folder.name + " " + ex.getMessage()); Log.i(folder.name + " fetching raw message uid=" + uid); - File file = File.createTempFile("serverbug", "." + uid, context.getCacheDir()); + File file = File.createTempFile("serverbug." + folder.id, "." + uid, context.getCacheDir()); try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { imessage.writeTo(os); } @@ -1933,7 +1933,7 @@ class Core { Log.i(folder.name + " decoding again uid=" + uid); try (InputStream is = new BufferedInputStream(new FileInputStream(file))) { - imessage = new MimeMessage(isession, is); + imessage = new MimeMessageEx(isession, is, imessage); } file.delete(); diff --git a/app/src/main/java/eu/faircode/email/MimeMessageEx.java b/app/src/main/java/eu/faircode/email/MimeMessageEx.java index 8b8abb3eea..046567b8ba 100644 --- a/app/src/main/java/eu/faircode/email/MimeMessageEx.java +++ b/app/src/main/java/eu/faircode/email/MimeMessageEx.java @@ -19,18 +19,27 @@ package eu.faircode.email; Copyright 2018-2019 by Marcel Bokhorst (M66B) */ +import java.io.InputStream; + +import javax.mail.Flags; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.internet.MimeMessage; public class MimeMessageEx extends MimeMessage { private String msgid; + private MimeMessage original; MimeMessageEx(Session session, String msgid) { super(session); this.msgid = msgid; } + MimeMessageEx(Session session, InputStream is, MimeMessage original) throws MessagingException { + super(session, is); + this.original = original; + } + @Override public String getMessageID() throws MessagingException { if (this.msgid == null) @@ -48,4 +57,12 @@ public class MimeMessageEx extends MimeMessage { Log.i("Override Message-ID=" + msgid); } } + + @Override + public synchronized boolean isSet(Flags.Flag flag) throws MessagingException { + if (original == null) + return super.isSet(flag); + else + return original.isSet(flag); + } }