From 948c89f5bb5538537ffe8ac2455b57b0d10891b1 Mon Sep 17 00:00:00 2001 From: Johannes Kanefendt Date: Wed, 4 Dec 2019 10:37:08 +0100 Subject: [PATCH] - Respect the user domain when dealing with groups - Renamed protocol MembershipAwareSource to SOGoMembershipSource --- .../Appointments/SOGoAppointmentFolder.m | 10 +++--- .../Appointments/SOGoAppointmentObject.m | 6 ++-- .../Appointments/SOGoCalendarComponent.m | 7 ++-- SoObjects/Mailer/SOGoMailFolder.m | 5 ++- SoObjects/SOGo/LDAPSource.h | 2 +- SoObjects/SOGo/SOGoGCSFolder.m | 36 +++++++++++-------- SoObjects/SOGo/SOGoSource.h | 2 +- UI/Contacts/UIxContactView.m | 4 +-- 8 files changed, 44 insertions(+), 28 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 4085fa2bf..b1f0a73d3 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -425,7 +425,7 @@ static Class iCalEventK = nil; response: (WOResponse *) theResponse { NSMutableDictionary *moduleSettings, *folderShowAlarms, *freeBusyExclusions; - NSString *subscriptionPointer; + NSString *subscriptionPointer, *domain; NSMutableArray *allUsers; SOGoUserSettings *us; NSDictionary *dict; @@ -438,16 +438,18 @@ static Class iCalEventK = nil; if (rc) { #warning Duplicated code from SOGoGCSFolder subscribeUserOrGroup - dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: theIdentifier]; + domain = [[context activeUser] domain]; + dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: theIdentifier + inDomain: domain]; if (dict && [[dict objectForKey: @"isGroup"] boolValue]) { id source; source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]]; - if ([source conformsToProtocol:@protocol(MembershipAwareSource)]) + if ([source conformsToProtocol:@protocol(SOGoMembershipSource)]) { - NSArray *members = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; + NSArray *members = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; allUsers = [NSMutableArray array]; for (i = 0; i < [members count]; i++) diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index ad9959d33..4bda36215 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -1624,7 +1624,7 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent iCalPerson *attendee; NSException *ex; SOGoUser *ownerUser, *delegatedUser; - NSString *recurrenceTime, *delegatedUid; + NSString *recurrenceTime, *delegatedUid, *domain; event = nil; ex = nil; @@ -1672,7 +1672,9 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent reason: @"delegate is a participant"]; else { NSDictionary *dict; - dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: [[delegate email] rfc822Email]]; + domain = [[context activeUser] domain]; + dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: [[delegate email] rfc822Email] + inDomain: domain]; if (dict && [[dict objectForKey: @"isGroup"] boolValue]) ex = [NSException exceptionWithHTTPStatus: 409 reason: @"delegate is a group"]; diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index 12704838b..21a85704b 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -549,7 +549,8 @@ pool = [[NSAutoreleasePool alloc] init]; } - dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: [currentAttendee rfc822Email]]; + dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: [currentAttendee rfc822Email] + inDomain: domain]; if (dict && [[dict objectForKey: @"isGroup"] boolValue]) { @@ -562,9 +563,9 @@ [allAttendees removeObject: currentAttendee]; source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]]; - if ([source conformsToProtocol:@protocol(MembershipAwareSource)]) + if ([source conformsToProtocol:@protocol(SOGoMembershipSource)]) { - members = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; + members = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; for (i = 0; i < [members count]; i++) { user = [members objectAtIndex: i]; diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index fd2933f22..f949c803c 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -1424,13 +1424,16 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data) - (NSString *) _sogoACLUIDToIMAPUID: (NSString *) uid { + NSString *domain; NSDictionary *dict; SOGoUser *user; if ([uid isEqualToString: defaultUserID]) return uid; - dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: uid]; + domain = [[context activeUser] domain]; + dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: uid + inDomain: domain]; if (dict && [[dict objectForKey: @"isGroup"] boolValue]) return [[[[context activeUser] domainDefaults] imapAclGroupIdPrefix] diff --git a/SoObjects/SOGo/LDAPSource.h b/SoObjects/SOGo/LDAPSource.h index 4adfda921..8f3f0a3d0 100644 --- a/SoObjects/SOGo/LDAPSource.h +++ b/SoObjects/SOGo/LDAPSource.h @@ -30,7 +30,7 @@ @class NSMutableDictionary; @class NSString; -@interface LDAPSource : NSObject +@interface LDAPSource : NSObject { int _queryLimit; int _queryTimeout; diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index e5d864f5a..69d41a90f 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -923,23 +923,25 @@ static NSArray *childRecordFields = nil; { NSMutableDictionary *moduleSettings, *folderShowAlarms; NSMutableArray *folderSubscription; - NSString *subscriptionPointer; + NSString *subscriptionPointer, *domain; NSMutableArray *allUsers; SOGoUserSettings *us; NSDictionary *dict; BOOL rc; int i; - dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: theIdentifier]; + domain = [[context activeUser] domain]; + dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: theIdentifier + inDomain: domain]; if (dict && [[dict objectForKey: @"isGroup"] boolValue]) { id source; source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]]; - if ([source conformsToProtocol:@protocol(MembershipAwareSource)]) + if ([source conformsToProtocol:@protocol(SOGoMembershipSource)]) { - NSArray *members = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; + NSArray *members = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; allUsers = [NSMutableArray array]; for (i = 0; i < [members count]; i++) @@ -1625,7 +1627,7 @@ static NSArray *childRecordFields = nil; { int count, max; NSDictionary *record; - NSString *currentUID; + NSString *currentUID, *domain; NSMutableArray *acls; acls = [NSMutableArray array]; @@ -1637,12 +1639,14 @@ static NSArray *childRecordFields = nil; currentUID = [record valueForKey: @"c_uid"]; if ([currentUID hasPrefix: @"@"]) { - NSString *dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: currentUID]; + domain = [[context activeUser] domain]; + NSString *dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: currentUID + inDomain: domain]; if (dict) { id source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]]; - if ([source conformsToProtocol:@protocol(MembershipAwareSource)] && - [(id)(source) groupWithUIDHasMemberWithUID: currentUID memberUid: uid]) + if ([source conformsToProtocol:@protocol(SOGoMembershipSource)] && + [(id)(source) groupWithUIDHasMemberWithUID: currentUID memberUid: uid]) [acls addObject: [record valueForKey: @"c_role"]]; } } @@ -1751,7 +1755,7 @@ static NSArray *childRecordFields = nil; forObjectAtPath: (NSArray *) objectPathArray { EOQualifier *qualifier; - NSString *uid, *uids, *qs, *objectPath; + NSString *uid, *uids, *qs, *objectPath, *domain; NSMutableArray *usersAndGroups, *groupsMembers; NSMutableDictionary *aclsForObject; @@ -1766,19 +1770,21 @@ static NSArray *childRecordFields = nil; NSDictionary *dict; uid = [usersAndGroups objectAtIndex: i]; - dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: uid]; + domain = [[context activeUser] domain]; + dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: uid + inDomain: domain]; if (dict && [[dict objectForKey: @"isGroup"] boolValue]) { id source; source = [[SOGoUserManager sharedUserManager] sourceWithID: [dict objectForKey: @"SOGoSource"]]; - if ([source conformsToProtocol:@protocol(MembershipAwareSource)]) + if ([source conformsToProtocol:@protocol(SOGoMembershipSource)]) { NSArray *members; NSDictionary *user; unsigned int j; // Fetch members to remove them from the cache along the group - members = [(id)(source) membersForGroupWithUID: uid]; + members = [(id)(source) membersForGroupWithUID: uid]; for (j = 0; j < [members count]; j++) { user = [members objectAtIndex: j]; @@ -1849,7 +1855,7 @@ static NSArray *childRecordFields = nil; forUser: (NSString *) uid forObjectAtPath: (NSArray *) objectPathArray { - NSString *objectPath, *aUID; + NSString *objectPath, *aUID, *domain; NSMutableArray *newRoles; objectPath = [objectPathArray componentsJoinedByString: @"/"]; @@ -1861,7 +1867,9 @@ static NSArray *childRecordFields = nil; if (![uid hasPrefix: @"@"]) { NSDictionary *dict; - dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: uid]; + domain = [[context activeUser] domain]; + dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: uid + inDomain: domain]; if ([[dict objectForKey: @"isGroup"] boolValue]) { aUID = [NSString stringWithFormat: @"@%@", uid]; diff --git a/SoObjects/SOGo/SOGoSource.h b/SoObjects/SOGo/SOGoSource.h index a9f1bddbe..a88983bfc 100644 --- a/SoObjects/SOGo/SOGoSource.h +++ b/SoObjects/SOGo/SOGoSource.h @@ -118,7 +118,7 @@ - (void) updateBaseDNFromLogin: (NSString *) theLogin; @end -@protocol MembershipAwareSource +@protocol SOGoMembershipSource - (NSArray *) membersForGroupWithUID: (NSString *) uid; - (BOOL) groupWithUIDHasMemberWithUID: (NSString *) uid memberUid: (NSString *) memberUid; diff --git a/UI/Contacts/UIxContactView.m b/UI/Contacts/UIxContactView.m index 4bb94bef9..d209d7074 100644 --- a/UI/Contacts/UIxContactView.m +++ b/UI/Contacts/UIxContactView.m @@ -407,9 +407,9 @@ if ([[dict objectForKey: @"isGroup"] boolValue]) { - if ([source conformsToProtocol:@protocol(MembershipAwareSource)]) + if ([source conformsToProtocol:@protocol(SOGoMembershipSource)]) { - allUsers = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; + allUsers = [(id)(source) membersForGroupWithUID: [dict objectForKey: @"c_uid"]]; max = [allUsers count]; allUsersData = [NSMutableArray arrayWithCapacity: max]; for (i = 0; i < max; i++)