fix(mail): add all unknown recipients to an address book

When SOGoMailAddOutgoingAddresses is enabled, all unknown recipients are
now added to the destination address book.
pull/283/head
Francis Lachapelle 2020-07-07 15:45:16 -04:00
parent f7e7612e05
commit d29c2b2c7b
1 changed files with 16 additions and 15 deletions

View File

@ -2004,6 +2004,9 @@ static NSString *userAgent = nil;
lookupName: @"Contacts"
inContext: context
acquire: NO];
// Get the selected addressbook from the user preferences where the new address will be added
addressBook = [ud selectedAddressBook];
folder = [contactFolders lookupName: addressBook inContext: context acquire: NO];
// Get all the recipients from the current email
recipients = [self allRecipients];
for (i = 0; i < [recipients count]; i++)
@ -2017,24 +2020,22 @@ static NSString *userAgent = nil;
matchingContacts = [contactFolders allContactsFromFilter: emailAddress
excludeGroups: YES
excludeLists: YES];
}
// If we don't get any results from the autocompletion code, we add it..
if ([matchingContacts count] == 0)
{
// Get the selected addressbook from the user preferences where the new address will be added
addressBook = [ud selectedAddressBook];
folder = [contactFolders lookupName: addressBook inContext: context acquire: NO];
uid = [folder globallyUniqueObjectId];
if (folder && uid)
// If we don't get any results from the autocompletion code, we add it..
if ([matchingContacts count] == 0)
{
card = [NGVCard cardWithUid: uid];
[card addEmail: emailAddress types: nil];
[card setFn: [parsedRecipient displayName]];
uid = [folder globallyUniqueObjectId];
newContact = [SOGoContactGCSEntry objectWithName: uid inContainer: folder];
[newContact setIsNew: YES];
[newContact saveComponent: card];
if (folder && uid)
{
card = [NGVCard cardWithUid: uid];
[card addEmail: emailAddress types: nil];
[card setFn: [parsedRecipient displayName]];
newContact = [SOGoContactGCSEntry objectWithName: uid inContainer: folder];
[newContact setIsNew: YES];
[newContact saveComponent: card];
}
}
}
}