Skip to content

Commit

Permalink
(fix) correctly set flags when ReplaceMime is set (fixes #4133)
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu committed Apr 7, 2017
1 parent 2e8c668 commit 8b307d8
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions ActiveSync/SOGoActiveSyncDispatcher.m
Expand Up @@ -3532,10 +3532,14 @@ - (void) _processSmartCommand: (id <DOMElement>) theDocumentElement
{
NSString *folderId, *itemId, *realCollectionId;
SOGoMicrosoftActiveSyncFolderType folderType;
SOGoMailAccounts *accountsFolder;
SOGoMailFolder *currentFolder;
SOGoUserFolder *userFolder;
SOGoMailObject *mailObject;
SOGoUserDefaults *ud;

BOOL htmlComposition, isHTML;
id value;
id value, currentCollection;

isHTML = NO;
ud = [[context activeUser] userDefaults];
Expand All @@ -3561,23 +3565,31 @@ - (void) _processSmartCommand: (id <DOMElement>) theDocumentElement

value = [theDocumentElement getElementsByTagName: @"ReplaceMime"];

// We fetch the mail object from the server
userFolder = [[context activeUser] homeFolderInContext: context];
accountsFolder = [userFolder lookupName: @"Mail" inContext: context acquire: NO];
currentFolder = [accountsFolder lookupName: @"0" inContext: context acquire: NO];

currentCollection = [currentFolder lookupName: [NSString stringWithFormat: @"folder%@", realCollectionId]
inContext: context
acquire: NO];

mailObject = [currentCollection lookupName: itemId inContext: context acquire: NO];

// ReplaceMime IS specified so we must NOT use the server copy
// but rather take the data as-is from the client.
if ([value count])
{
[self processSendMail: theDocumentElement
inResponse: theResponse];
[self processSendMail: theDocumentElement inResponse: theResponse];
if (!isSmartForward)
[mailObject addFlags: @"Answered"];
else
[mailObject addFlags: @"$Forwarded"];
return;
}

if (folderType == ActiveSyncMailFolder)
{
SOGoMailAccounts *accountsFolder;
SOGoMailFolder *currentFolder;
SOGoUserFolder *userFolder;
SOGoMailObject *mailObject;
id currentCollection;

NGMimeMessage *messageFromSmartForward, *messageToSend;
NGMimeMessageParser *parser;
NSData *data;
Expand All @@ -3596,16 +3608,6 @@ - (void) _processSmartCommand: (id <DOMElement>) theDocumentElement

int a;

userFolder = [[context activeUser] homeFolderInContext: context];
accountsFolder = [userFolder lookupName: @"Mail" inContext: context acquire: NO];
currentFolder = [accountsFolder lookupName: @"0" inContext: context acquire: NO];

currentCollection = [currentFolder lookupName: [NSString stringWithFormat: @"folder%@", realCollectionId]
inContext: context
acquire: NO];

mailObject = [currentCollection lookupName: itemId inContext: context acquire: NO];

parser = [[NGMimeMessageParser alloc] init];
data = [[[[(id)[theDocumentElement getElementsByTagName: @"MIME"] lastObject] textValue] stringByDecodingBase64] dataUsingEncoding: NSUTF8StringEncoding];
messageFromSmartForward = [parser parsePartFromData: data];
Expand Down

0 comments on commit 8b307d8

Please sign in to comment.