Check cross account move conditions

This commit is contained in:
M66B 2019-01-25 07:48:07 +00:00
parent aaafa4275a
commit abfa20cb84
3 changed files with 25 additions and 1 deletions

View File

@ -2084,6 +2084,18 @@ public class FragmentMessages extends FragmentBase {
EntityMessage message = db.message().getMessage(target.id);
if (message != null) {
Log.i("Move id=" + target.id + " target=" + target.folder.name);
// Cross account move: check if message downloaded
if (!target.folder.account.equals(message.account)) {
if (!message.content)
throw new IllegalArgumentException(getString(R.string.title_no_accross));
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
for (EntityAttachment attachment : attachments)
if (!attachment.available)
throw new IllegalArgumentException(getString(R.string.title_no_accross));
}
EntityOperation.queue(context, db, message, EntityOperation.MOVE, target.folder.id);
}
}
@ -2097,7 +2109,10 @@ public class FragmentMessages extends FragmentBase {
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.execute(FragmentMessages.this, args, "messages:move");
}

View File

@ -1675,6 +1675,14 @@ public class ServiceSynchronize extends LifecycleService {
}
private void doAdd(EntityFolder folder, Session isession, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException, IOException {
if (!message.content)
throw new IllegalArgumentException("Message body missing");
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
for (EntityAttachment attachment : attachments)
if (!attachment.available)
throw new IllegalArgumentException("Attachment missing");
// Append message
MimeMessage imessage = MessageHelper.from(this, message, isession);

View File

@ -306,6 +306,7 @@
<string name="title_no_stream">An outdated app sent a file path instead of a file stream</string>
<string name="title_no_contacts">Contact picker not available</string>
<string name="title_no_internet">No internet connection</string>
<string name="title_no_accross">Moving across accounts requires all message content to be downloaded</string>
<string name="title_raw_saved">Raw message saved</string>
<string name="title_attachment_saved">Attachment saved</string>
<string name="title_attachments_saved">Attachments saved</string>