Delete messages by msgid

pull/147/head
M66B 6 years ago
parent d5dc15884e
commit d912aab5dc

@ -1617,16 +1617,13 @@ public class FragmentCompose extends FragmentEx {
}
// Delete draft (cannot move to outbox)
draft.msgid = null;
draft.ui_hide = true;
db.message().updateMessage(draft);
EntityOperation.queue(db, draft, EntityOperation.DELETE);
// Copy message to outbox
draft.id = null;
draft.folder = db.folder().getOutbox().id;
draft.uid = null;
draft.msgid = msgid;
draft.msgid = EntityMessage.generateMessageId();
draft.ui_hide = false;
draft.id = db.message().insertMessage(draft);
draft.write(getContext(), body);

@ -117,6 +117,7 @@ import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.search.ComparisonTerm;
import javax.mail.search.FlagTerm;
import javax.mail.search.MessageIDTerm;
import javax.mail.search.OrTerm;
import javax.mail.search.ReceivedDateTerm;
import javax.net.ssl.SSLException;
@ -1431,6 +1432,7 @@ public class ServiceSynchronize extends LifecycleService {
if (message != null && message.uid == null &&
!(EntityOperation.ADD.equals(op.name) ||
EntityOperation.DELETE.equals(op.name) ||
EntityOperation.SEND.equals(op.name) ||
EntityOperation.SYNC.equals(op.name)))
throw new IllegalArgumentException(op.name + " without uid " + op.args);
@ -1667,12 +1669,14 @@ public class ServiceSynchronize extends LifecycleService {
private void doDelete(EntityFolder folder, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException {
// Delete message
Message imessage = ifolder.getMessageByUID(message.uid);
if (imessage == null)
throw new MessageRemovedException();
imessage.setFlag(Flags.Flag.DELETED, true);
ifolder.expunge();
if (message.msgid != null) {
Message[] imessages = ifolder.search(new MessageIDTerm(message.msgid));
for (Message imessage : imessages) {
Log.i(Helper.TAG, "Deleting uid=" + message.uid + " msgid=" + message.msgid);
imessage.setFlag(Flags.Flag.DELETED, true);
}
ifolder.expunge();
}
db.message().deleteMessage(message.id);
}

Loading…
Cancel
Save