Blame SOURCES/evolution-ews-3.28.5-save-only-if-organizer.patch

688341
diff -up evolution-ews-3.28.5/src/calendar/e-cal-backend-ews.c.save-only-if-organizer evolution-ews-3.28.5/src/calendar/e-cal-backend-ews.c
688341
--- evolution-ews-3.28.5/src/calendar/e-cal-backend-ews.c.save-only-if-organizer	2019-11-13 07:44:37.295278517 +0100
688341
+++ evolution-ews-3.28.5/src/calendar/e-cal-backend-ews.c	2019-11-13 07:55:27.656269523 +0100
688341
@@ -147,6 +147,41 @@ ecb_ews_get_collection_settings (ECalBac
688341
 	return CAMEL_EWS_SETTINGS (settings);
688341
 }
688341
 
688341
+static GHashTable *
688341
+ecb_ews_get_mail_aliases (ECalBackendEws *cbews)
688341
+{
688341
+	ESource *source;
688341
+	ESourceRegistry *registry;
688341
+	GHashTable *aliases = NULL;
688341
+	GList *identities, *link;
688341
+	const gchar *parent_uid;
688341
+
688341
+	source = e_backend_get_source (E_BACKEND (cbews));
688341
+	parent_uid = e_source_get_parent (source);
688341
+
688341
+	if (!parent_uid || !*parent_uid)
688341
+		return NULL;
688341
+
688341
+	registry = e_cal_backend_get_registry (E_CAL_BACKEND (cbews));
688341
+	identities = e_source_registry_list_enabled (registry, E_SOURCE_EXTENSION_MAIL_IDENTITY);
688341
+
688341
+	for (link = identities; link; link = g_list_next (link)) {
688341
+		ESource *mail_identity = link->data;
688341
+
688341
+		if (g_strcmp0 (parent_uid, e_source_get_parent (mail_identity)) == 0) {
688341
+			ESourceMailIdentity *extension;
688341
+
688341
+			extension = e_source_get_extension (mail_identity, E_SOURCE_EXTENSION_MAIL_IDENTITY);
688341
+			aliases = e_source_mail_identity_get_aliases_as_hash_table (extension);
688341
+			break;
688341
+		}
688341
+	}
688341
+
688341
+	g_list_free_full (identities, g_object_unref);
688341
+
688341
+	return aliases;
688341
+}
688341
+
688341
 static void
688341
 ecb_ews_convert_error_to_edc_error (GError **perror)
688341
 {
688341
@@ -1350,6 +1385,18 @@ ecb_ews_is_organizer (ECalBackendEws *cb
688341
 		is_organizer = user_email && g_ascii_strcasecmp (email, user_email) == 0;
688341
 
688341
 		g_free (user_email);
688341
+
688341
+		if (!is_organizer) {
688341
+			GHashTable *aliases;
688341
+
688341
+			aliases = ecb_ews_get_mail_aliases (cbews);
688341
+
688341
+			if (aliases) {
688341
+				is_organizer = g_hash_table_contains (aliases, email);
688341
+
688341
+				g_hash_table_unref (aliases);
688341
+			}
688341
+		}
688341
 	}
688341
 
688341
 	return is_organizer;
688341
@@ -2595,6 +2642,10 @@ ecb_ews_save_component_sync (ECalMetaBac
688341
 		g_slist_free_full (existing, g_object_unref);
688341
 		g_slist_free_full (changed_instances, change_data_free);
688341
 		g_slist_free_full (removed_instances, g_object_unref);
688341
+	} else if (e_cal_component_has_organizer (master) &&
688341
+		   !ecb_ews_is_organizer (cbews, master)) {
688341
+		success = FALSE;
688341
+		g_propagate_error (error, EDC_ERROR_EX (PermissionDenied, _("Cannot create meetings organized by other users in an Exchange Web Services calendar.")));
688341
 	} else {
688341
 		GHashTable *removed_indexes;
688341
 		EwsCalendarConvertData convert_data = { 0 };