Navigation Menu

Skip to content

Commit

Permalink
Newly subscribed calendars are excluded from FB
Browse files Browse the repository at this point in the history
Fixes #3354
  • Loading branch information
cgx committed May 30, 2017
1 parent b3149ee commit 95d08c0
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 16 deletions.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -11,6 +11,7 @@ Bug fixes
- [core] handle properly mails using windows-1255 charset (#4124)
- [core] properly honor the "include in freebusy" setting (#3354)
- [core] make sure to use crypt scheme when encoding md5/sha256/sha512 (#4137)
- [core] newly subscribed calendars are excluded from freebusy (#3354)
- [web] fixed mail delegation of pristine user accounts (#4160)
- [eas] fixed opacity in EAS freebusy (#4033)
- [eas] set reply/forwarded flags when ReplaceMime is set (#4133)
Expand Down
98 changes: 96 additions & 2 deletions SoObjects/Appointments/SOGoAppointmentFolder.m
Expand Up @@ -434,6 +434,93 @@ - (void) setShowCalendarTasks: (BOOL) new
inCategory: @"FolderShowTasks"];
}

- (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier
reallyDo: (BOOL) reallyDo
response: (WOResponse *) theResponse
{
NSMutableDictionary *moduleSettings, *folderShowAlarms, *freeBusyExclusions;
NSString *subscriptionPointer;
NSMutableArray *allUsers;
SOGoUserSettings *us;
NSDictionary *dict;
SOGoUser *sogoUser;
BOOL rc;
int i;

rc = [super subscribeUserOrGroup: theIdentifier reallyDo: reallyDo response: theResponse];

if (rc)
{
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: theIdentifier];

if ([[dict objectForKey: @"isGroup"] boolValue])
{
SOGoGroup *aGroup;

aGroup = [SOGoGroup groupWithIdentifier: theIdentifier
inDomain: [[context activeUser] domain]];
allUsers = [NSMutableArray arrayWithArray: [aGroup members]];

// We remove the active user from the group (if present) in order to
// not subscribe him to their own resource!
[allUsers removeObject: [context activeUser]];
}
else
{
sogoUser = [SOGoUser userWithLogin: theIdentifier roles: nil];

if (sogoUser)
allUsers = [NSArray arrayWithObject: sogoUser];
else
allUsers = [NSArray array];
}

for (i = 0; i < [allUsers count]; i++)
{
sogoUser = [allUsers objectAtIndex: i];
us = [sogoUser userSettings];
moduleSettings = [us objectForKey: [container nameInContainer]];
if (!(moduleSettings
&& [moduleSettings isKindOfClass: [NSMutableDictionary class]]))
{
moduleSettings = [NSMutableDictionary dictionary];
[us setObject: moduleSettings forKey: [container nameInContainer]];
}

subscriptionPointer = [self folderReference];

folderShowAlarms = [moduleSettings objectForKey: @"FolderShowAlarms"];
freeBusyExclusions = [moduleSettings objectForKey: @"FreeBusyExclusions"];

if (reallyDo)
{
if (!(folderShowAlarms
&& [folderShowAlarms isKindOfClass: [NSMutableDictionary class]]))
{
folderShowAlarms = [NSMutableDictionary dictionary];
[moduleSettings setObject: folderShowAlarms
forKey: @"FolderShowAlarms"];
}

// By default, we disable alarms on subscribed calendars
[folderShowAlarms setObject: [NSNumber numberWithBool: NO]
forKey: subscriptionPointer];
}
else
{
[folderShowAlarms removeObjectForKey: subscriptionPointer];
[freeBusyExclusions removeObjectForKey: subscriptionPointer];
}

[us synchronize];

rc = YES;
}
}

return rc;
}

//
// If the user is the owner of the calendar, by default we include the freebusy information.
//
Expand Down Expand Up @@ -461,9 +548,16 @@ - (BOOL) includeInFreeBusy
= [self folderPropertyValueInCategory: @"FreeBusyExclusions"
forUser: [SOGoUser userWithLogin: ownerInContext]];

// We haven't included/excluded freebusy info, let's INCLUDE it.
// User has not setting for freebusy inclusion/exclusion,
// * include it if it's a personal folder;
// * exclude it if it's a subscription.
if (!excludeFromFreeBusy)
return YES;
{
if ([self isSubscription])
return NO;
else
return YES;
}

return ![excludeFromFreeBusy boolValue];
}
Expand Down
19 changes: 5 additions & 14 deletions SoObjects/SOGo/SOGoGCSFolder.m
Expand Up @@ -970,8 +970,12 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier

folderSubscription = [moduleSettings objectForKey: @"SubscribedFolders"];
subscriptionPointer = [self folderReference];


// We used to set "show alarms" for any type of folder, so we remove it
// here and let the subclass handle it (SOGoAppointmentFolder).
folderShowAlarms = [moduleSettings objectForKey: @"FolderShowAlarms"];
if (folderShowAlarms)
[folderShowAlarms removeObjectForKey: subscriptionPointer];

if (reallyDo)
{
Expand All @@ -983,30 +987,17 @@ - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier
forKey: @"SubscribedFolders"];
}

if (!(folderShowAlarms
&& [folderShowAlarms isKindOfClass: [NSMutableDictionary class]]))
{
folderShowAlarms = [NSMutableDictionary dictionary];
[moduleSettings setObject: folderShowAlarms
forKey: @"FolderShowAlarms"];
}

[self setFolderPropertyValue: [self _displayNameFromSubscriber]
inCategory: @"FolderDisplayNames"
settings: us];

[folderSubscription addObjectUniquely: subscriptionPointer];

// By default, we disable alarms on subscribed calendars
[folderShowAlarms setObject: [NSNumber numberWithBool: NO]
forKey: subscriptionPointer];
}
else
{
[self removeFolderSettings: moduleSettings
withReference: subscriptionPointer];
[folderSubscription removeObject: subscriptionPointer];
[folderShowAlarms removeObjectForKey: subscriptionPointer];
}

[us synchronize];
Expand Down

0 comments on commit 95d08c0

Please sign in to comment.