[evolution] I#1985 - Composer: Send of Outbox message doesn't remove it



commit c4f2a875b34f566a6b523231ba4a8672bc034e8d
Author: Milan Crha <mcrha redhat com>
Date:   Tue Aug 16 11:11:12 2022 +0200

    I#1985 - Composer: Send of Outbox message doesn't remove it
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1985

 src/mail/em-composer-utils.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
---
diff --git a/src/mail/em-composer-utils.c b/src/mail/em-composer-utils.c
index ebd6df7a26..83b3a51330 100644
--- a/src/mail/em-composer-utils.c
+++ b/src/mail/em-composer-utils.c
@@ -608,6 +608,7 @@ composer_send_completed (GObject *source_object,
                          gpointer user_data)
 {
        EActivity *activity;
+       const gchar *outbox_uid;
        gboolean service_unavailable;
        gboolean set_changed = FALSE;
        AsyncContext *async_context;
@@ -707,6 +708,28 @@ composer_send_completed (GObject *source_object,
                goto exit;
        }
 
+       /* Remove the Outbox message after successful send */
+       outbox_uid = e_msg_composer_get_header (async_context->composer, "X-Evolution-Outbox-UID", 0);
+       if (outbox_uid && *outbox_uid) {
+               CamelSession *session;
+               CamelFolder *outbox;
+
+               session = e_msg_composer_ref_session (async_context->composer);
+               outbox = e_mail_session_get_local_folder (E_MAIL_SESSION (session), 
E_MAIL_LOCAL_FOLDER_OUTBOX);
+               if (outbox) {
+                       CamelMessageInfo *info;
+
+                       info = camel_folder_get_message_info (outbox, outbox_uid);
+                       if (info) {
+                               camel_message_info_set_flags (info, CAMEL_MESSAGE_DELETED, 
CAMEL_MESSAGE_DELETED);
+
+                               g_clear_object (&info);
+                       }
+               }
+
+               g_clear_object (&session);
+       }
+
        e_activity_set_state (activity, E_ACTIVITY_COMPLETED);
 
        /* Wait for the EActivity's completion message to
@@ -2364,6 +2387,13 @@ em_utils_edit_message (EMsgComposer *composer,
                }
        }
 
+       if (message_uid != NULL && folder_is_outbox) {
+               /* To remove the message after send */
+               e_msg_composer_set_header (
+                       composer, "X-Evolution-Outbox-UID",
+                       message_uid);
+       }
+
        composer_set_no_change (composer);
 
        gtk_widget_show (GTK_WIDGET (composer));


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