Get flags from original message

This commit is contained in:
M66B 2019-09-29 11:43:00 +02:00
parent c5848917a6
commit e2e948d104
2 changed files with 19 additions and 2 deletions

View File

@ -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();

View File

@ -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);
}
}