[geary/mjog/fix-null-message-ids: 1/4] Ensure ComposerWidget checks referred email for required fields



commit 35cfacd18ed61518bd4bed6508643392bd93b300
Author: Michael Gratton <mike vee net>
Date:   Fri Nov 1 15:38:45 2019 +1100

    Ensure ComposerWidget checks referred email for required fields
    
    This is a safety check to catch programming errors, mostly.

 src/client/composer/composer-widget.vala | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 8585cfa0..28cdf959 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -16,6 +16,9 @@ private errordomain AttachmentError {
 public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
 
 
+    /** The email fields the composer requires for referred email. */
+    public const Geary.Email.Field REQUIRED_FIELDS = ENVELOPE | BODY;
+
     public enum ComposeType {
         NEW_MESSAGE,
         REPLY,
@@ -621,6 +624,12 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
     public async void load(Geary.Email? referred = null,
                            string? quote = null,
                            GLib.Cancellable? cancellable) {
+        if (referred != null &&
+            !referred.fields.is_all_set(REQUIRED_FIELDS)) {
+            throw new Geary.EngineError.INCOMPLETE_MESSAGE(
+                "Required fields not met: %s", referred.fields.to_string()
+            );
+        }
         bool is_referred_draft = (
             referred != null &&
             this.draft_id != null &&


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]