Support moving from/to drafts

This commit is contained in:
M66B 2019-06-24 09:07:43 +02:00
parent 0ed815fff7
commit da0f528798
1 changed files with 19 additions and 1 deletions

View File

@ -591,6 +591,24 @@ class Core {
throw new FolderNotFoundException(); throw new FolderNotFoundException();
IMAPFolder itarget = (IMAPFolder) istore.getFolder(target.name); IMAPFolder itarget = (IMAPFolder) istore.getFolder(target.name);
if (EntityFolder.DRAFTS.equals(folder.type) || EntityFolder.DRAFTS.equals(target.type)) {
Log.i(folder.name + " move from " + folder.type + " to " + target.type);
File file = message.getRawFile(context);
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
imessage.writeTo(os);
}
Message icopy;
try (InputStream is = new BufferedInputStream(new FileInputStream(file))) {
icopy = new MimeMessage(isession, is);
}
file.delete();
icopy.setFlag(Flags.Flag.DRAFT, EntityFolder.DRAFTS.equals(target.type));
itarget.appendMessages(new Message[]{icopy});
} else
ifolder.copyMessages(new Message[]{imessage}, itarget); ifolder.copyMessages(new Message[]{imessage}, itarget);
// Delete source // Delete source