Delete messages without ID by uid

pull/154/head
M66B 6 years ago
parent f42d624285
commit 19a407cf31

@ -544,10 +544,15 @@ class Core {
// Delete message // Delete message
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
Message[] imessages;
if (TextUtils.isEmpty(message.msgid)) if (TextUtils.isEmpty(message.msgid))
throw new IllegalArgumentException("Message ID missing"); if (message.uid == null)
throw new IllegalArgumentException("Delete without ID");
else
imessages = new Message[]{ifolder.getMessageByUID(message.uid)};
else
imessages = ifolder.search(new MessageIDTerm(message.msgid));
Message[] imessages = ifolder.search(new MessageIDTerm(message.msgid));
for (Message imessage : imessages) { for (Message imessage : imessages) {
Log.i(folder.name + " deleting uid=" + message.uid + " msgid=" + message.msgid); Log.i(folder.name + " deleting uid=" + message.uid + " msgid=" + message.msgid);
try { try {
@ -555,6 +560,7 @@ class Core {
} catch (MessageRemovedException ignored) { } catch (MessageRemovedException ignored) {
} }
} }
ifolder.expunge(); ifolder.expunge();
db.message().deleteMessage(message.id); db.message().deleteMessage(message.id);

Loading…
Cancel
Save