1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-01 04:35:57 +00:00

Fix, refactoring

This commit is contained in:
M66B 2019-03-14 10:00:31 +00:00
parent 0ca0ca6479
commit 5b2cb2e604

View file

@ -423,7 +423,7 @@ class Core {
imessage.setFlag(Flags.Flag.DRAFT, true); imessage.setFlag(Flags.Flag.DRAFT, true);
// Add message // Add message
long uid = append(istore, ifolder, imessage); long uid = append(ifolder, imessage);
Log.i(folder.name + " appended id=" + message.id + " uid=" + uid); Log.i(folder.name + " appended id=" + message.id + " uid=" + uid);
db.message().setMessageUid(message.id, uid); db.message().setMessageUid(message.id, uid);
@ -526,11 +526,7 @@ class Core {
icopy.setFlag(Flags.Flag.DRAFT, true); icopy.setFlag(Flags.Flag.DRAFT, true);
// Append target // Append target
long uid = append(istore, itarget, (MimeMessage) icopy); long uid = append(itarget, (MimeMessage) icopy);
// Fixed timing issue of at least Courier based servers
itarget.close(false);
itarget.open(Folder.READ_WRITE);
// Some providers, like Gmail, don't honor the appended seen flag // Some providers, like Gmail, don't honor the appended seen flag
if (itarget.getPermanentFlags().contains(Flags.Flag.SEEN)) { if (itarget.getPermanentFlags().contains(Flags.Flag.SEEN)) {
@ -669,12 +665,20 @@ class Core {
parts.downloadAttachment(context, sequence - 1, attachment.id); parts.downloadAttachment(context, sequence - 1, attachment.id);
} }
private static long append(IMAPStore istore, IMAPFolder ifolder, MimeMessage imessage) throws MessagingException { private static long append(IMAPFolder ifolder, MimeMessage imessage) throws MessagingException {
String msgid = imessage.getMessageID();
if (msgid == null)
throw new IllegalArgumentException("Message ID missing");
ifolder.appendMessages(new Message[]{imessage}); ifolder.appendMessages(new Message[]{imessage});
long uid = -1; // Fixed timing issue of at least Courier based servers
String msgid = imessage.getMessageID(); ifolder.close(false);
ifolder.open(Folder.READ_WRITE);
Log.i("Searching for appended msgid=" + msgid); Log.i("Searching for appended msgid=" + msgid);
long uid = -1;
Message[] messages = ifolder.search(new MessageIDTerm(msgid)); Message[] messages = ifolder.search(new MessageIDTerm(msgid));
if (messages != null) if (messages != null)
for (Message iappended : messages) { for (Message iappended : messages) {