(fix) safeguard ourselves againts mailboxes with no quota

This commit is contained in:
Ludovic Marcotte 2016-01-12 15:57:43 -05:00
parent 98e780dc6f
commit d2f164dfb7

View file

@ -287,17 +287,19 @@
- (WOResponse *) batchDeleteAction
{
SOGoMailFolder *co;
SOGoMailAccount *account;
SOGoUserSettings *us;
WORequest *request;
WOResponse *response;
id uids;
NSDictionary *data;
BOOL withTrash;
NSMutableDictionary *moduleSettings, *threadsCollapsed;
NSString *currentMailbox, *currentAccount, *keyForMsgUIDs;
NSMutableArray *mailboxThreadsCollapsed;
SOGoMailAccount *account;
SOGoUserSettings *us;
WOResponse *response;
SOGoMailFolder *co;
NSDictionary *data;
WORequest *request;
id uids, quota;
BOOL withTrash;
int i;
response = nil;
@ -315,10 +317,17 @@
{
// When not using a trash folder, return the quota
account = [co mailAccountFolder];
data = [NSDictionary dictionaryWithObjectsAndKeys: [account getInboxQuota], @"quotas", nil];
quota = [account getInboxQuota];
if (quota)
{
data = [NSDictionary dictionaryWithObjectsAndKeys: quota, @"quotas", nil];
response = [self responseWithStatus: 200
andString: [data jsonRepresentation]];
}
else
response = [self responseWithStatus: 200];
}
else
{
// Verify if the message beeing delete is saved as the root of a collapsed thread
@ -412,6 +421,8 @@
NSDictionary *data;
NSArray *uids;
id quota;
co = [self clientObject];
data = [[[context request] contentAsString] objectFromJSONString];
uids = [data objectForKey: @"uids"];
@ -425,9 +436,16 @@
{
// We return the inbox quota
account = [co mailAccountFolder];
data = [NSDictionary dictionaryWithObject: [account getInboxQuota] forKey: @"quotas"];
quota = [account getInboxQuota];
if (quota)
{
data = [NSDictionary dictionaryWithObject: quota forKey: @"quotas"];
response = [self responseWithStatus: 200 andJSONRepresentation: data];
}
else
response = [self responseWithStatus: 200];
}
}
else
{