diff --git a/app/src/main/java/eu/faircode/email/EntityFolder.java b/app/src/main/java/eu/faircode/email/EntityFolder.java index ac000ba90d..54cad8b5d2 100644 --- a/app/src/main/java/eu/faircode/email/EntityFolder.java +++ b/app/src/main/java/eu/faircode/email/EntityFolder.java @@ -221,6 +221,16 @@ public class EntityFolder extends EntityOrder implements Serializable { } } + static EntityFolder getOutbox() { + EntityFolder outbox = new EntityFolder(); + outbox.name = "OUTBOX"; + outbox.type = EntityFolder.OUTBOX; + outbox.synchronize = false; + outbox.sync_days = 0; + outbox.keep_days = 0; + return outbox; + } + static String getNotificationChannelId(long id) { return "notification.folder." + id; } diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index b100cacc2f..0181e87fa9 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -3905,8 +3905,11 @@ public class FragmentCompose extends FragmentBase { EntityOperation.queue(context, draft, EntityOperation.DELETE); EntityFolder outbox = db.folder().getOutbox(); - if (outbox == null) - throw new IllegalArgumentException("Outbox missing"); + if (outbox == null) { + Log.e("Outbox missing"); + outbox = EntityFolder.getOutbox(); + outbox.id = db.folder().insertFolder(outbox); + } // Copy message to outbox draft.id = null; diff --git a/app/src/main/java/eu/faircode/email/FragmentSetup.java b/app/src/main/java/eu/faircode/email/FragmentSetup.java index da8c2f1173..578dfd45e4 100644 --- a/app/src/main/java/eu/faircode/email/FragmentSetup.java +++ b/app/src/main/java/eu/faircode/email/FragmentSetup.java @@ -320,12 +320,7 @@ public class FragmentSetup extends FragmentBase { EntityFolder outbox = db.folder().getOutbox(); if (outbox == null) { - outbox = new EntityFolder(); - outbox.name = "OUTBOX"; - outbox.type = EntityFolder.OUTBOX; - outbox.synchronize = false; - outbox.sync_days = 0; - outbox.keep_days = 0; + outbox = EntityFolder.getOutbox(); outbox.id = db.folder().insertFolder(outbox); }