mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-14 11:23:19 +00:00
Fix JSON error responses
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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]];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user