mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-23 15:12:44 +00:00
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.
This commit is contained in:
1
NEWS
1
NEWS
@@ -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)
|
||||
-------------------
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user