fix(core): don't auto-remove a subscription if any source is in error

This commit is contained in:
Francis Lachapelle
2022-05-11 16:29:49 -04:00
parent ab5f5abc80
commit 373ac51e62
6 changed files with 65 additions and 11 deletions
+5
View File
@@ -497,6 +497,11 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses
return (NGLdapConnection *)[self connection];
}
- (BOOL) isConnected
{
return [[self _ldapConnection] isBound];
}
- (void) releaseConnection: (id) connection
{
if ([(NGLdapConnection *)connection isBound])
+29 -9
View File
@@ -1,6 +1,6 @@
/* SOGoParentFolder.m - this file is part of SOGo
*
* Copyright (C) 2006-2017 Inverse inc.
* Copyright (C) 2006-2022 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -36,7 +36,9 @@
#import "NSObject+DAV.h"
#import "SOGoGCSFolder.h"
#import "SOGoPermissions.h"
#import "SOGoSource.h"
#import "SOGoUser.h"
#import "SOGoUserManager.h"
#import "SOGoWebDAVAclManager.h"
#import "SOGoParentFolder.h"
@@ -307,15 +309,17 @@ static SoSecurityManager *sm = nil;
- (NSException *) appendSubscribedSources
{
NSMutableDictionary *folderDisplayNames;
NSMutableArray *subscribedReferences;
SOGoUserSettings *settings;
NSString *activeUser, *currentKey;
SOGoUser *ownerUser;
BOOL dirty, safeCheck, isConnected;
NSEnumerator *sources;
NSException *error;
NSMutableArray *subscribedReferences;
NSMutableDictionary *folderDisplayNames;
NSObject <SOGoSource> *currentSource;
NSString *activeUser, *domain, *currentKey;
SOGoUser *ownerUser;
SOGoUserSettings *settings;
id o;
int i;
BOOL dirty;
if (!subscribedSubFolders)
subscribedSubFolders = [NSMutableDictionary new];
@@ -325,8 +329,11 @@ static SoSecurityManager *sm = nil;
error = nil; /* we ignore non-DB errors at this time... */
dirty = NO;
safeCheck = NO;
isConnected = YES;
activeUser = [[context activeUser] login];
domain = [[context activeUser] domain];
ownerUser = [SOGoUser userWithLogin: owner];
settings = [ownerUser userSettings];
@@ -348,8 +355,21 @@ static SoSecurityManager *sm = nil;
[subscribedReferences removeObject: currentKey];
[folderDisplayNames removeObjectForKey: currentKey];
if ([owner isEqualToString: activeUser])
// Synchronize settings only if the subscription is owned by the active user
dirty = YES;
{
// Safe check -- don't remove the subscription if any of the users sources has a connection failure.
if (!safeCheck)
{
safeCheck = YES;
sources = [[[SOGoUserManager sharedUserManager] sourcesInDomain: domain] objectEnumerator];
while (isConnected && (currentSource = [sources nextObject]))
{
isConnected = isConnected && [currentSource isConnected];
}
}
if (isConnected)
// Synchronize settings only if the subscription is owned by the active user
dirty = YES;
}
}
}
+1
View File
@@ -43,6 +43,7 @@
- (id) connection;
- (void) releaseConnection: (id) connection;
- (BOOL) isConnected;
/* requires a "." to obtain the full list of contacts */
- (void) setListRequiresDot: (BOOL) aBool;
+2 -1
View File
@@ -1,6 +1,6 @@
/* SOGoUserManager.h - this file is part of SOGo
*
* Copyright (C) 2007-2015 Inverse inc.
* Copyright (C) 2007-2022 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -54,6 +54,7 @@
- (NSString *) registryClass;
- (NSArray *) sourcesInDomain: (NSString *) domain;
- (NSArray *) sourceIDsInDomain: (NSString *) domain;
- (NSArray *) authenticationSourceIDsInDomain: (NSString *) domain;
- (NSArray *) addressBookSourceIDsInDomain: (NSString *) domain;
+23 -1
View File
@@ -1,6 +1,6 @@
/* SOGoUserManager.m - this file is part of SOGo
*
* Copyright (C) 2007-2015 Inverse inc.
* Copyright (C) 2007-2021 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -212,6 +212,28 @@ static Class NSNullK;
return @"SOGoUserManagerRegistry";
}
- (NSArray *) sourcesInDomain: (NSString *) domain
{
NSMutableArray *sources;
NSArray *allSources;
int count, max;
NSString *sourceDomain;
NSObject <SOGoSource> *currentSource;
allSources = [_sources allValues];
max = [allSources count];
sources = [NSMutableArray arrayWithCapacity: max];
for (count = 0; count < max; count++)
{
currentSource = [allSources objectAtIndex: count];
sourceDomain = [currentSource domain];
if (![sourceDomain length] || [sourceDomain isEqualToString: domain])
[sources addObject: currentSource];
}
return sources;
}
- (NSArray *) sourceIDsInDomain: (NSString *) domain
{
NSMutableArray *sourceIDs;
+5
View File
@@ -445,6 +445,11 @@
return channel;
}
- (BOOL) isConnected
{
return [self connection];
}
- (void) releaseConnection: (id) connection
{
GCSChannelManager *cm;