From 18df3bafb5096c123c117d8cf1085d250254f112 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 30 Aug 2018 21:51:39 -0400 Subject: [PATCH] Fix JSON error responses --- UI/Common/UIxFolderActions.m | 6 +++--- UI/Common/UIxObjectActions.m | 2 +- UI/Common/UIxParentFolderActions.m | 4 ++-- UI/Common/UIxUserRightsEditor.m | 4 ++-- UI/MailerUI/UIxMailFolderActions.m | 10 +++++----- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/UI/Common/UIxFolderActions.m b/UI/Common/UIxFolderActions.m index 422a3234c..034413c8d 100644 --- a/UI/Common/UIxFolderActions.m +++ b/UI/Common/UIxFolderActions.m @@ -84,7 +84,7 @@ if ([owner isEqualToString: login]) { jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"You cannot (un)subscribe to a folder that you own!"] - forKey: @"error"]; + forKey: @"message"]; response = [self responseWithStatus: 403 andJSONRepresentation: jsonResponse]; } @@ -294,7 +294,7 @@ } else { - message = [NSDictionary dictionaryWithObject: @"Missing name parameter" forKey: @"error"]; + message = [NSDictionary dictionaryWithObject: @"Missing name parameter" forKey: @"message"]; response = [self responseWithStatus: 500 andString: [message jsonRepresentation]]; } @@ -335,7 +335,7 @@ { response = [self responseWithStatus: 400 andJSONRepresentation: [NSDictionary dictionaryWithObject: @"At least 1 id required." - forKey: @"error"]]; + forKey: @"message"]]; } return response; diff --git a/UI/Common/UIxObjectActions.m b/UI/Common/UIxObjectActions.m index 19042f5d3..9ade2d9ee 100644 --- a/UI/Common/UIxObjectActions.m +++ b/UI/Common/UIxObjectActions.m @@ -103,7 +103,7 @@ if (response) { - data = [NSDictionary dictionaryWithObjectsAndKeys: [(NSException *) response reason], @"error", nil]; + data = [NSDictionary dictionaryWithObjectsAndKeys: [(NSException *) response reason], @"message", nil]; response = [self responseWithStatus: 403 andJSONRepresentation: data]; } diff --git a/UI/Common/UIxParentFolderActions.m b/UI/Common/UIxParentFolderActions.m index e98c55061..da43860a3 100644 --- a/UI/Common/UIxParentFolderActions.m +++ b/UI/Common/UIxParentFolderActions.m @@ -79,14 +79,14 @@ } else { - data = [NSDictionary dictionaryWithObjectsAndKeys: @"That name already exists", @"error", nil]; + data = [NSDictionary dictionaryWithObjectsAndKeys: @"That name already exists", @"message", nil]; response = [self responseWithStatus: 409 andString: [data jsonRepresentation]]; } } else { - data = [NSDictionary dictionaryWithObjectsAndKeys: @"The name is missing", @"error", nil]; + data = [NSDictionary dictionaryWithObjectsAndKeys: @"The name is missing", @"message", nil]; response = [self responseWithStatus: 400 andString: [data jsonRepresentation]]; } diff --git a/UI/Common/UIxUserRightsEditor.m b/UI/Common/UIxUserRightsEditor.m index 75af44603..a9da6726e 100644 --- a/UI/Common/UIxUserRightsEditor.m +++ b/UI/Common/UIxUserRightsEditor.m @@ -217,7 +217,7 @@ if (![self _initRights]) { jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"No such user."] - forKey: @"error"]; + forKey: @"message"]; response = [self responseWithStatus: 403 andString: [jsonResponse jsonRepresentation]]; } @@ -274,7 +274,7 @@ if (!([self _initRightsForUserID: currentUid])) { jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"No such user."] - forKey: @"error"]; + forKey: @"message"]; response = [self responseWithStatus: 403 andString: [jsonResponse jsonRepresentation]]; break; diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index bf2d26a09..c002b1efb 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -85,14 +85,14 @@ { errorFormat = [self labelForKey: @"The folder with name \"%@\" could not be created." inContext: context]; jsonResponse = [NSDictionary dictionaryWithObject: [NSString stringWithFormat: errorFormat, folderName] - forKey: @"error"]; + forKey: @"message"]; response = [self responseWithStatus: 500 andJSONRepresentation: jsonResponse]; } } else { jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"Missing 'name' parameter." inContext: context] - forKey: @"error"]; + forKey: @"message"]; response = [self responseWithStatus: 500 andJSONRepresentation: jsonResponse]; } @@ -401,7 +401,7 @@ if (error) { jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"Unable to move/delete folder." inContext: context] - forKey: @"error"]; + forKey: @"message"]; response = [self responseWithStatus: 500 andJSONRepresentation: jsonResponse]; } else @@ -428,7 +428,7 @@ if (error) { jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"Unable to move/delete folder." inContext: context] - forKey: @"error"]; + forKey: @"message"]; response = [self responseWithStatus: 500 andJSONRepresentation: jsonResponse]; } else @@ -993,7 +993,7 @@ { result = [NSDictionary dictionaryWithObject: [self labelForKey: @"Missing 'flags' and 'msgUIDs' parameters." inContext: context] - forKey: @"error"]; + forKey: @"message"]; response = [self responseWithStatus: 500 andJSONRepresentation: result]; } else