(json) Return ACLs when subscribing to a folder

pull/201/head
Francis Lachapelle 2016-03-04 09:54:20 -05:00
parent 5aa19ebfb7
commit f19b213c02
1 changed files with 13 additions and 0 deletions

View File

@ -75,8 +75,11 @@
- (WOResponse *) _subscribeAction: (BOOL) reallyDo
{
WOResponse *response;
NSArray *allACLs;
NSDictionary *jsonResponse;
NSMutableDictionary *acls;
NSURL *mailInvitationURL;
BOOL objectCreator, objectEditor, objectEraser;
response = nil;
[self _setupContext];
@ -102,6 +105,15 @@
}
else
{
// We extract ACLs for this address book
allACLs = ([owner isEqualToString: login] ? nil : [clientObject aclsForUser: login]);
objectCreator = ([owner isEqualToString: login] || [allACLs containsObject: SOGoRole_ObjectCreator]);
objectEditor = ([owner isEqualToString: login] || [allACLs containsObject: SOGoRole_ObjectEditor]);
objectEraser = ([owner isEqualToString: login] || [allACLs containsObject: SOGoRole_ObjectEraser]);
acls = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool: objectCreator], @"objectCreator",
[NSNumber numberWithBool: objectEditor], @"objectEditor",
[NSNumber numberWithBool: objectEraser], @"objectEraser", nil];
// @see [SOGoGCSFolder folderWithSubscriptionReference:inContainer:]
jsonResponse
= [NSDictionary dictionaryWithObjectsAndKeys:
@ -112,6 +124,7 @@
[NSNumber numberWithBool:
[clientObject isKindOfClass: [SOGoContactSourceFolder class]]
&& ![(SOGoContactSourceFolder *) clientObject isPersonalSource]], @"isRemote",
acls, @"acls",
nil];
response = [self responseWithStatus: 200
andJSONRepresentation: jsonResponse];