mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-05 12:24:26 +01:00
Check cross account move conditions
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user