From 5b6096e32ce2c31b7b1d5b849b1ad7e8209c08a2 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Tue, 26 May 2020 09:25:25 -0400 Subject: [PATCH] fix(core): improve debbuging when dealing with groups --- .../Appointments/SOGoAppointmentFolder.m | 10 ++++-- .../Appointments/SOGoCalendarComponent.m | 6 ++++ SoObjects/SOGo/SOGoGCSFolder.m | 31 +++++++++++++++---- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 413b74597..9dc48dbe8 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -430,7 +430,6 @@ static Class iCalEventK = nil; NSMutableArray *allUsers; SOGoUserSettings *us; NSDictionary *dict; - SOGoUser *sogoUser; BOOL rc; int i; @@ -450,7 +449,9 @@ static Class iCalEventK = nil; source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]]; if ([source conformsToProtocol:@protocol(SOGoMembershipSource)]) { - NSArray *members = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; + NSArray *members; + + members = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; allUsers = [NSMutableArray array]; for (i = 0; i < [members count]; i++) @@ -461,6 +462,11 @@ static Class iCalEventK = nil; // not subscribe him to their own resource! [allUsers removeObject: [[context activeUser] login]]; } + else + { + [self errorWithFormat: @"Inconsistency error - got group identifier (%@) from a source (%@) that does not support groups.", theIdentifier, [dict objectForKey: @"SOGoSource"]]; + return NO; + } } else { diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index 4881bc73c..846c09a93 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -587,6 +587,12 @@ [allAttendees addObject: person]; } } + else + { + [self errorWithFormat: @"Inconsistency error - got group identifier (%@) from a source (%@) that does not support groups.", [currentAttendee rfc822Email], [dict objectForKey: @"SOGoSource"]]; + RELEASE(pool); + return NO; + } } j++; diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 69d41a90f..9ed312c76 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -941,7 +941,9 @@ static NSArray *childRecordFields = nil; source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]]; if ([source conformsToProtocol:@protocol(SOGoMembershipSource)]) { - NSArray *members = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; + NSArray *members; + + members = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; allUsers = [NSMutableArray array]; for (i = 0; i < [members count]; i++) @@ -952,6 +954,11 @@ static NSArray *childRecordFields = nil; // not subscribe him to their own resource! [allUsers removeObject: [[context activeUser] login]]; } + else + { + [self errorWithFormat: @"Inconsistency error - got group identifier (%@) from a source (%@) that does not support groups.", theIdentifier, [dict objectForKey: @"SOGoSource"]]; + return NO; + } } else { @@ -1626,7 +1633,7 @@ static NSArray *childRecordFields = nil; matchingUID: (NSString *) uid { int count, max; - NSDictionary *record; + NSDictionary *record, *dict; NSString *currentUID, *domain; NSMutableArray *acls; @@ -1640,14 +1647,21 @@ static NSArray *childRecordFields = nil; if ([currentUID hasPrefix: @"@"]) { domain = [[context activeUser] domain]; - NSString *dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: currentUID - inDomain: domain]; + dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: currentUID + inDomain: domain]; if (dict) { id source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]]; if ([source conformsToProtocol:@protocol(SOGoMembershipSource)] && [(id)(source) groupWithUIDHasMemberWithUID: currentUID memberUid: uid]) - [acls addObject: [record valueForKey: @"c_role"]]; + { + [acls addObject: [record valueForKey: @"c_role"]]; + } + else + { + [self errorWithFormat: @"Inconsistency error - got group identifier (%@) from a source (%@) that does not support groups.", currentUID, [dict objectForKey: @"SOGoSource"]]; + return [NSArray array]; + } } } } @@ -1779,8 +1793,8 @@ static NSArray *childRecordFields = nil; source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]]; if ([source conformsToProtocol:@protocol(SOGoMembershipSource)]) { - NSArray *members; NSDictionary *user; + NSArray *members; unsigned int j; // Fetch members to remove them from the cache along the group @@ -1796,6 +1810,11 @@ static NSArray *childRecordFields = nil; [usersAndGroups replaceObjectAtIndex: i withObject: [NSString stringWithFormat: @"@%@", uid]]; } + else + { + [self errorWithFormat: @"Inconsistency error - got group identifier (%@) from a source (%@) that does not support groups.", uid, [dict objectForKey: @"SOGoSource"]]; + return; + } } } objectPath = [objectPathArray componentsJoinedByString: @"/"];