Skip to content

Commit

Permalink
(fix) handle 120 EAS status code when message submission fails (fixes…
Browse files Browse the repository at this point in the history
… #3774)
  • Loading branch information
extrafu committed Sep 23, 2016
1 parent 300a893 commit 9bbffe4
Showing 1 changed file with 45 additions and 5 deletions.
50 changes: 45 additions & 5 deletions ActiveSync/SOGoActiveSyncDispatcher.m
Expand Up @@ -3240,8 +3240,28 @@ - (void) processSendMail: (id <DOMElement>) theDocumentElement

if (error)
{
[theResponse setStatus: 500];
[theResponse appendContentString: @"FATAL ERROR occured during SendMail"];
if ([[context objectForKey: @"ASProtocolVersion"] floatValue] >= 14.0)
{
NSMutableString *s;
NSData *d;

s = [NSMutableString string];

[s appendString: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"];
[s appendString: @"<!DOCTYPE ActiveSync PUBLIC \"-//MICROSOFT//DTD ActiveSync//EN\" \"http://www.microsoft.com/\">"];
[s appendString: @"<SendMail xmlns=\"ComposeMail:\">"];
[s appendString: @"<Status>120</Status>"];
[s appendString: @"</SendMail>"];

d = [[s dataUsingEncoding: NSUTF8StringEncoding] xml2wbxml];

[theResponse setContent: d];
}
else
{
[theResponse setStatus: 500];
[theResponse appendContentString: @"FATAL ERROR occured during SendMail"];
}
}
}

Expand Down Expand Up @@ -3748,8 +3768,28 @@ - (void) _processSmartCommand: (id <DOMElement>) theDocumentElement

if (error)
{
[theResponse setStatus: 500];
[theResponse appendContentString: @"FATAL ERROR occured during SmartForward"];
if ([[context objectForKey: @"ASProtocolVersion"] floatValue] >= 14.0)
{
NSMutableString *s;
NSData *d;

s = [NSMutableString string];

[s appendString: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"];
[s appendString: @"<!DOCTYPE ActiveSync PUBLIC \"-//MICROSOFT//DTD ActiveSync//EN\" \"http://www.microsoft.com/\">"];
[s appendFormat: @"<%@ xmlns=\"ComposeMail:\">", (isSmartForward) ? @"SmartForward" : @"SmartReply"];
[s appendString: @"<Status>120</Status>"];
[s appendFormat: @"</%@>", (isSmartForward) ? @"SmartForward" : @"SmartReply"];

d = [[s dataUsingEncoding: NSUTF8StringEncoding] xml2wbxml];

[theResponse setContent: d];
}
else
{
[theResponse setStatus: 500];
[theResponse appendContentString: @"FATAL ERROR occured during SmartForward"];
}
}
else if (!isSmartForward)
{
Expand Down Expand Up @@ -3957,7 +3997,7 @@ - (NSException *) dispatchRequest: (id) theRequest
[theResponse setHeader: @"Sync,SendMail,SmartForward,SmartReply,GetAttachment,GetHierarchy,CreateCollection,DeleteCollection,MoveCollection,FolderSync,FolderCreate,FolderDelete,FolderUpdate,MoveItems,GetItemEstimate,MeetingResponse,Search,Settings,Ping,ItemOperations,ResolveRecipients,ValidateCert" forKey: @"MS-ASProtocolCommands"];
[theResponse setHeader: @"2.5,12.0,12.1,14.0,14.1" forKey: @"MS-ASProtocolVersions"];

if (debugOn && [[theResponse headerForKey: @"Content-Type"] isEqualToString:@"application/vnd.ms-sync.wbxml"] && [[theResponse content] length])
if (debugOn && [[theResponse headerForKey: @"Content-Type"] isEqualToString:@"application/vnd.ms-sync.wbxml"] && [[theResponse content] length] && !([(WOResponse *)theResponse status] == 500))
[self logWithFormat: @"EAS - response for device %@: %@", [context objectForKey: @"DeviceId"], [[[NSString alloc] initWithData: [[theResponse content] wbxml2xml] encoding: NSUTF8StringEncoding] autorelease]];

RELEASE(context);
Expand Down

0 comments on commit 9bbffe4

Please sign in to comment.