Skip to content

Commit

Permalink
compare both email and name before skipping vcard import
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoh committed Aug 25, 2024
1 parent 8a6ba22 commit 9e5a18e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions program/actions/contacts/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,25 @@ public function run($args = [])

if (!$replace) {
$existing = null;
$search_fields = [];
$search_values = [];

// compare e-mail address
if ($email) {
$existing = $CONTACTS->search('email', $email, 1, false);
$search_fields[] = 'email';
$search_values[] = $email;
}
// compare display name if email not found
if ((!$existing || !$existing->count) && $vcard->displayname) {
$existing = $CONTACTS->search('name', $vcard->displayname, 1, false);

if ($vcard->displayname) {
$search_fields[] = 'name';
$search_values[] = $vcard->displayname;
}

// compare email and/or display name if available
if (!empty($search_fields)) {
$existing = $CONTACTS->search($search_fields, $search_values, 1, false);
}

if ($existing && $existing->count) {
self::$stats->skipped++;
self::$stats->skipped_names[] = $vcard->displayname ?: $email;
Expand Down

0 comments on commit 9e5a18e

Please sign in to comment.