From e01985e910eef4753e3bc8de82381a01d68c37f7 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Sat, 10 Mar 2012 04:44:31 +0000 Subject: [PATCH] Monotone-Parent: 5e1d3b05e4ac96fabc257b4fb753b7c7439c8337 Monotone-Revision: facc7e6b6f1dbd15663b7472ae5447106a067e21 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-03-10T04:44:31 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++ OpenChange/MAPIStoreMailVolatileMessage.m | 63 ++++++++++++----------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 876e5e7e6..f24dbf222 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2012-03-09 Wolfgang Sourdeau + * OpenChange/MAPIStoreMailVolatileMessage.m (-submitWithFlags:): + skip any message that is not of class "IPM.Note", in order to + avoid sending invitations or responses. + * SoObjects/Mailer/SOGoMailFolder.m (-renameTo:): reset the imap4URL to nil and change the nameInContainer after a successful operation. diff --git a/OpenChange/MAPIStoreMailVolatileMessage.m b/OpenChange/MAPIStoreMailVolatileMessage.m index a8e06b92c..2d5a937e5 100644 --- a/OpenChange/MAPIStoreMailVolatileMessage.m +++ b/OpenChange/MAPIStoreMailVolatileMessage.m @@ -774,50 +774,55 @@ MakeMessageBody (NSDictionary *mailProperties, NSDictionary *attachmentParts, NSData *messageData; NSMutableArray *recipientEmails; NSArray *list; - NSString *recId; + NSString *recId, *from, *msgClass; NSUInteger count; - struct mapistore_connection_info *connInfo; SOGoUser *activeUser; - NSString *from; // SOGoMailFolder *sentFolder; SOGoDomainDefaults *dd; NSException *error; MAPIStoreMapping *mapping; - /* send mail */ - - messageData = [self _generateMailDataWithBcc: NO]; - mailProperties = [sogoObject properties]; - recipientEmails = [NSMutableArray arrayWithCapacity: 32]; - recipients = [mailProperties objectForKey: @"recipients"]; - for (count = 0; count < 3; count++) + msgClass = [mailProperties objectForKey: MAPIPropertyKey (PidTagMessageClass)]; + if ([msgClass isEqualToString: @"IPM.Note"]) /* we skip invitation replies */ { - recId = recTypes[count]; - list = [recipients objectForKey: recId]; - [recipientEmails - addObjectsFromArray: [list objectsForKey: @"email" - notFoundMarker: nil]]; - } + /* send mail */ - connInfo = [[self context] connectionInfo]; - activeUser = [SOGoUser userWithLogin: [NSString stringWithUTF8String: connInfo->username]]; + messageData = [self _generateMailDataWithBcc: NO]; + + mailProperties = [sogoObject properties]; + recipientEmails = [NSMutableArray arrayWithCapacity: 32]; + recipients = [mailProperties objectForKey: @"recipients"]; + for (count = 0; count < 3; count++) + { + recId = recTypes[count]; + list = [recipients objectForKey: recId]; + [recipientEmails + addObjectsFromArray: [list objectsForKey: @"email" + notFoundMarker: nil]]; + } - [self logWithFormat: @"recipients: %@", recipientEmails]; - dd = [activeUser domainDefaults]; - from = [[activeUser allEmails] objectAtIndex: 0]; - error = [[SOGoMailer mailerWithDomainDefaults: dd] + activeUser = [[self context] activeUser]; + + [self logWithFormat: @"recipients: %@", recipientEmails]; + dd = [activeUser domainDefaults]; + from = [[activeUser allEmails] objectAtIndex: 0]; + error = [[SOGoMailer mailerWithDomainDefaults: dd] sendMailData: messageData toRecipients: recipientEmails sender: from]; - if (error) - [self logWithFormat: @"an error occurred: '%@'", error]; + if (error) + [self logWithFormat: @"an error occurred: '%@'", error]; - mapping = [self mapping]; - [mapping unregisterURLWithID: [self objectId]]; - [self setIsNew: NO]; - [properties removeAllObjects]; - [[self container] cleanupCaches]; + mapping = [self mapping]; + [mapping unregisterURLWithID: [self objectId]]; + [self setIsNew: NO]; + [properties removeAllObjects]; + [[self container] cleanupCaches]; + } + else + [self logWithFormat: @"skipping submit of message with class '%@'", + msgClass]; return MAPISTORE_SUCCESS; }