diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-06-22 22:22:27 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-06-22 22:22:27 +0300 |
commit | 8344d7626627db2f65306af0ea358fa3956e7c69 (patch) | |
tree | 85d3afe15b27105916abfe6a9bace6f4feb6b3db /lib/Service | |
parent | 980ef3d53352cff0385ec5ba1e71b474f00b5d27 (diff) |
Handle missing fullname in contacts integration
… and fall back to the email as dropdown label.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Service')
-rw-r--r-- | lib/Service/ContactsIntegration.php | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/Service/ContactsIntegration.php b/lib/Service/ContactsIntegration.php index 52c32582f..b06c535e2 100644 --- a/lib/Service/ContactsIntegration.php +++ b/lib/Service/ContactsIntegration.php @@ -63,7 +63,7 @@ class ContactsIntegration { } $id = $r['UID']; - $fn = $r['FN']; + $fn = $r['FN'] ?? null; if (!isset($r['EMAIL'])) { continue; } @@ -78,12 +78,22 @@ class ContactsIntegration { if ($e === '') { continue; } - $receivers[] = [ - 'id' => $id, - 'label' => "$fn ($e)", - 'email' => $e, - 'photo' => $photo, - ]; + // Show full name if possible or fall back to email + if ($fn !== null) { + $receivers[] = [ + 'id' => $id, + 'label' => "$fn ($e)", + 'email' => $e, + 'photo' => $photo, + ]; + } else { + $receivers[] = [ + 'id' => $id, + 'label' => $e, + 'email' => $e, + 'photo' => $photo, + ]; + } } } @@ -133,16 +143,16 @@ class ContactsIntegration { } $result = $this->contactsManager->search($uid, ['UID'], ['types' => true, 'limit' => 1]); - + if (count($result) !== 1) { return null; // no match } - + $newEntry = [ 'type' => $type, 'value' => $mailAddr ]; - + $match = $result[0]; $email = $match['EMAIL'] ?? []; if (!empty($email) && !is_array($email[0])) { |