Fix contacts lookup by UID

When looking for a specific contact UID, we no longer match a pattern
that could return multiple results. We search for the exact UID only.
pull/72/head
Francis Lachapelle 2015-03-03 21:18:46 -05:00
parent 6192322513
commit 8e0849029e
4 changed files with 30 additions and 9 deletions

1
NEWS
View File

@ -12,6 +12,7 @@ Bug fixes
- SmartReply improvements for missing body attributes
- do not use syncKey from cache when davCollectionTag = -1
- use correct mail attachment elements for EAS 2.5 clients
- fixed contacts lookup by UID in freebusy
2.2.16 (2015-02-12)
-------------------

View File

@ -62,17 +62,14 @@
SOGoUserManager *um;
NSString *domain;
NSDictionary *contactInfos;
NSArray *contacts;
um = [SOGoUserManager sharedUserManager];
contactInfos = [um contactInfosForUserWithUIDorEmail: uid];
if (contactInfos == nil)
{
// Search among global addressbooks
domain = [[context activeUser] domain];
[um fetchContactsMatching: uid inDomain: domain];
contacts = [um fetchContactsMatching: uid inDomain: domain];
if ([contacts count] == 1)
contactInfos = [contacts lastObject];
contactInfos = [um fetchContactWithUID: uid inDomain: domain];
}
/* iCal.app compatibility:
@ -279,7 +276,6 @@
if ([uid length])
{
SOGoUserManager *um;
NSArray *contacts;
NSString *domain, *email;
NSDictionary *contact;
MSExchangeFreeBusy *exchangeFreeBusy;
@ -287,10 +283,9 @@
um = [SOGoUserManager sharedUserManager];
domain = [[context activeUser] domain];
contacts = [um fetchContactsMatching: uid inDomain: domain];
if ([contacts count] == 1)
contact = [um fetchContactWithUID: uid inDomain: domain];
if (contact)
{
contact = [contacts lastObject];
email = [contact valueForKey: @"c_email"];
source = [contact objectForKey: @"source"];
if ([email length]

View File

@ -65,10 +65,13 @@
- (NSDictionary *) contactInfosForUserWithUIDorEmail: (NSString *) uid;
- (NSDictionary *) contactInfosForUserWithUIDorEmail: (NSString *) uid
inDomain: (NSString *) domain;
- (NSDictionary *) fetchContactWithUID: (NSString *) uid
inDomain: (NSString *) domain;
- (NSArray *) fetchContactsMatching: (NSString *) match
inDomain: (NSString *) domain;
- (NSArray *) fetchUsersMatching: (NSString *) filter
inDomain: (NSString *) domain;
- (NSArray *) _compactAndCompleteContacts: (NSEnumerator *) contacts;
- (NSString *) getCNForUID: (NSString *) uid;
- (NSString *) getEmailForUID: (NSString *) uid;

View File

@ -915,6 +915,28 @@ static Class NSNullK;
return currentUser;
}
/**
* Fetch the contact information identified by the specified UID in the global addressbooks.
*/
- (NSDictionary *) fetchContactWithUID: (NSString *) uid
inDomain: (NSString *) domain
{
NSMutableArray *contacts;
NSEnumerator *sources;
NSString *sourceID;
id currentSource;
contacts = [NSMutableArray array];
sources = [[self addressBookSourceIDsInDomain: domain] objectEnumerator];
while ((sourceID = [sources nextObject]))
{
currentSource = [_sources objectForKey: sourceID];
[contacts addObject: [currentSource lookupContactEntry: uid]];
}
return [[self _compactAndCompleteContacts: [contacts objectEnumerator]] lastObject];
}
- (NSArray *) _compactAndCompleteContacts: (NSEnumerator *) contacts
{
NSMutableDictionary *compactContacts, *returnContact;