From d95b90281b8d42246186d6a112cbfad9d7c5a119 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 27 Jul 2016 12:02:00 -0400 Subject: [PATCH] Expunge drafts mailbox when a draft is sent --- NEWS | 1 + SoObjects/Mailer/SOGoDraftObject.m | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index d3c73cd63..96329d0df 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ New features - [eas] added folder merging capabilities Enhancements + - [web] expunge drafts mailbox when a draft is sent and deleted Bug fixes - [eas] fixed long GUID issue preventing sometimes synchronisation (#3460) diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m index 5237fc98d..2d07ab481 100644 --- a/SoObjects/Mailer/SOGoDraftObject.m +++ b/SoObjects/Mailer/SOGoDraftObject.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2007-2014 Inverse inc. + Copyright (C) 2007-2016 Inverse inc. Copyright (C) 2004-2005 SKYRIX Software AG This file is part of SOGo. @@ -15,7 +15,7 @@ License for more details. You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the + License along with SOGo; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -73,6 +73,7 @@ #import "NSData+Mail.h" #import "NSString+Mail.h" +#import "SOGoDraftsFolder.h" #import "SOGoMailAccount.h" #import "SOGoMailFolder.h" #import "SOGoMailObject.h" @@ -1979,8 +1980,16 @@ static NSString *userAgent = nil; } } - if (!error && ![dd mailKeepDraftsAfterSend]) - [self delete]; + // Expunge Drafts mailbox if + // - message was sent and saved to Sent mailbox if necessary; + // - SOGoMailKeepDraftsAfterSend is not set; + // - draft is successfully deleted; + // - drafts mailbox exists. + if (!error && + ![dd mailKeepDraftsAfterSend] && + ![self delete] && + [imap4 doesMailboxExistAtURL: [container imap4URL]]) + [(SOGoDraftsFolder *) container expunge]; return error; }