[evolution] itip-formatter: Doesn't match attendee when an alias address is used



commit 45dc6b1ad61d26a9bc853f9ce502caf0771c2628
Author: Milan Crha <mcrha redhat com>
Date:   Wed Aug 21 10:31:00 2019 +0200

    itip-formatter: Doesn't match attendee when an alias address is used
    
    When the component has set an alias address of an attendee, the attendee
    was not matched when the folder of the message was for an account with
    mail identity, which resulted in adding a new attendee with a new
    address, instead of updating existing attendee.
    
    Related to https://gitlab.gnome.org/GNOME/evolution-ews/issues/55

 src/modules/itip-formatter/itip-view.c | 44 ++++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 12 deletions(-)
---
diff --git a/src/modules/itip-formatter/itip-view.c b/src/modules/itip-formatter/itip-view.c
index ca971d8d4e..16d55739d1 100644
--- a/src/modules/itip-formatter/itip-view.c
+++ b/src/modules/itip-formatter/itip-view.c
@@ -3282,28 +3282,27 @@ find_to_address (ItipView *view,
        if (view->priv->to_address != NULL)
                return;
 
-       if (view->priv->message != NULL && view->priv->folder != NULL) {
+       /* Look through the list of attendees to find the user's address */
+       list = e_source_registry_list_enabled (registry, extension_name);
+
+       if (view->priv->message && view->priv->folder) {
                ESource *source;
 
                source = em_utils_guess_mail_identity (
                        registry, view->priv->message,
                        view->priv->folder, view->priv->message_uid);
 
-               if (source != NULL) {
-                       extension = e_source_get_extension (source, extension_name);
-
-                       view->priv->to_address = e_source_mail_identity_dup_address (extension);
+               if (source) {
+                       if (g_list_find (list, source)) {
+                               list = g_list_remove (list, source);
+                               g_object_unref (source);
+                       }
 
-                       g_object_unref (source);
+                       /* Try the account where the message is located first */
+                       list = g_list_prepend (list, source);
                }
        }
 
-       if (view->priv->to_address != NULL)
-               return;
-
-       /* Look through the list of attendees to find the user's address */
-       list = e_source_registry_list_enabled (registry, extension_name);
-
        for (link = list; link != NULL; link = g_list_next (link)) {
                ESource *source = E_SOURCE (link->data);
                ICalProperty *prop;
@@ -3465,6 +3464,27 @@ find_to_address (ItipView *view,
        }
 
        g_list_free_full (list, (GDestroyNotify) g_object_unref);
+
+       if (view->priv->to_address)
+               return;
+
+       /* Guess based on the message location only as the last resort, because
+          the attendee in the list of attendees is required. */
+       if (view->priv->message && view->priv->folder) {
+               ESource *source;
+
+               source = em_utils_guess_mail_identity (
+                       registry, view->priv->message,
+                       view->priv->folder, view->priv->message_uid);
+
+               if (source) {
+                       extension = e_source_get_extension (source, extension_name);
+
+                       view->priv->to_address = e_source_mail_identity_dup_address (extension);
+
+                       g_object_unref (source);
+               }
+       }
 }
 
 static void


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