Return properties of folder upon subscribe (JSON)

This commit is contained in:
Francis Lachapelle 2014-11-10 15:08:23 -05:00
parent 93540b4fc6
commit 7812e3757d
2 changed files with 35 additions and 22 deletions

View file

@ -32,16 +32,17 @@
#import <NGObjWeb/SoClassSecurityInfo.h> #import <NGObjWeb/SoClassSecurityInfo.h>
#import <NGObjWeb/NSException+HTTP.h> #import <NGObjWeb/NSException+HTTP.h>
#import <SoObjects/SOGo/SOGoUserManager.h> #import <SOGo/SOGoUserManager.h>
#import <SoObjects/SOGo/NSArray+Utilities.h> #import <SOGo/NSArray+Utilities.h>
#import <SoObjects/SOGo/NSDictionary+Utilities.h> #import <SOGo/NSDictionary+Utilities.h>
#import <SoObjects/SOGo/NSString+Utilities.h> #import <SOGo/NSString+Utilities.h>
#import <SoObjects/SOGo/SOGoContentObject.h> #import <SOGo/SOGoContentObject.h>
#import <SoObjects/SOGo/SOGoGCSFolder.h> #import <SOGo/SOGoGCSFolder.h>
#import <SoObjects/SOGo/SOGoParentFolder.h> #import <SOGo/SOGoParentFolder.h>
#import <SoObjects/SOGo/SOGoPermissions.h> #import <SOGo/SOGoPermissions.h>
#import <SoObjects/SOGo/SOGoUser.h> #import <SOGo/SOGoUser.h>
#import <SoObjects/SOGo/SOGoUserSettings.h> #import <SOGo/SOGoUserSettings.h>
#import <Contacts/SOGoContactSourceFolder.h>
#import "WODirectAction+SOGo.h" #import "WODirectAction+SOGo.h"
@ -76,18 +77,17 @@
- (WOResponse *) _subscribeAction: (BOOL) reallyDo - (WOResponse *) _subscribeAction: (BOOL) reallyDo
{ {
WOResponse *response; WOResponse *response;
NSDictionary *jsonResponse;
NSURL *mailInvitationURL; NSURL *mailInvitationURL;
response = [context response]; response = nil;
[response setHeader: @"text/plain; charset=utf-8"
forKey: @"Content-Type"];
[self _setupContext]; [self _setupContext];
if ([owner isEqualToString: login]) if ([owner isEqualToString: login])
{ {
[response setStatus: 403]; jsonResponse = [NSDictionary dictionaryWithObject: [self labelForKey: @"You cannot (un)subscribe to a folder that you own!"]
[response appendContentString: forKey: @"error"];
@"You cannot (un)subscribe to a folder that you own!"]; response = [self responseWithStatus: 403
andJSONRepresentation: jsonResponse];
} }
else else
{ {
@ -97,14 +97,27 @@
if (isMailInvitation) if (isMailInvitation)
{ {
mailInvitationURL mailInvitationURL = [clientObject soURLToBaseContainerForCurrentUser];
= [clientObject soURLToBaseContainerForCurrentUser]; response = [self responseWithStatus: 302];
[response setStatus: 302];
[response setHeader: [mailInvitationURL absoluteString] [response setHeader: [mailInvitationURL absoluteString]
forKey: @"location"]; forKey: @"location"];
} }
else else
[response setStatus: 204]; {
// @see [SOGoGCSFolder folderWithSubscriptionReference:inContainer:]
jsonResponse
= [NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat: @"%@_%@", [owner asCSSIdentifier], [clientObject nameInContainer]], @"id",
owner, @"owner",
[clientObject displayName], @"name",
[NSNumber numberWithBool: [clientObject isKindOfClass: [SOGoGCSFolder class]]], @"isEditable",
[NSNumber numberWithBool:
[clientObject isKindOfClass: [SOGoContactSourceFolder class]]
&& ![(SOGoContactSourceFolder *) clientObject isPersonalSource]], @"isRemote",
nil];
response = [self responseWithStatus: 200
andJSONRepresentation: jsonResponse];
}
} }
return response; return response;

View file

@ -1,5 +1,5 @@
{ /* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ { /* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
requires = ( MAIN, Mailer ); requires = ( MAIN, Contacts, Mailer );
publicResources = ( publicResources = (
calendar.css, calendar.css,