diff --git a/Classes/MagicSearch.swift b/Classes/MagicSearch.swift index 6d732e44d..65aa033b3 100644 --- a/Classes/MagicSearch.swift +++ b/Classes/MagicSearch.swift @@ -58,6 +58,11 @@ import linphonesw func searchAndAddMatchingContact(searchResult: SearchResult) -> Contact? { if let friend = searchResult.friend { + if (searchResult.sourceFlags == MagicSearchSource.LdapServers.rawValue), let newContact = Contact(friend: friend.getCobject) { + // Contact comes from LDAP, creating a new one + newContact.createdFromLdap = true + return newContact + } if let addr = friend.address, let foundContact = getContactFromAddr(addr: addr) { return foundContact } @@ -66,11 +71,6 @@ import linphonesw return foundContact } } - // No contacts found (searchResult likely comes from LDAP), creating a new one - if let newContact = Contact(friend: friend.getCobject) { - newContact.createdFromLdap = true - return newContact - } } if let addr = searchResult.address, let foundContact = getContactFromAddr(addr: addr) {