Skip to content

Commit c53edf5

Browse files
Add fallback options for contacts array
when the UID or FN is null, the email address / dsiplay name will be used instead Signed-off-by: Anna Larch <anna@nextcloud.com>
1 parent 34ca126 commit c53edf5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/private/Collaboration/Collaborators/MailPlugin.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
165165
if (!$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
166166
$singleResult = [[
167167
'label' => $displayName,
168-
'uuid' => $contact['UID'],
169-
'name' => $contact['FN'],
168+
'uuid' => $contact['UID'] ?? $emailAddress,
169+
'name' => $contact['FN'] ?? $displayName,
170170
'value' => [
171171
'shareType' => IShare::TYPE_USER,
172172
'shareWith' => $cloud->getUser(),
@@ -205,8 +205,8 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
205205
if ($addToWide && !$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
206206
$userResults['wide'][] = [
207207
'label' => $displayName,
208-
'uuid' => $contact['UID'],
209-
'name' => $contact['FN'],
208+
'uuid' => $contact['UID'] ?? $emailAddress,
209+
'name' => $contact['FN'] ?? $displayName,
210210
'value' => [
211211
'shareType' => IShare::TYPE_USER,
212212
'shareWith' => $cloud->getUser(),
@@ -226,8 +226,8 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
226226
}
227227
$result['exact'][] = [
228228
'label' => $displayName,
229-
'uuid' => $contact['UID'],
230-
'name' => $contact['FN'],
229+
'uuid' => $contact['UID'] ?? $emailAddress,
230+
'name' => $contact['FN'] ?? $displayName,
231231
'type' => $emailAddressType ?? '',
232232
'value' => [
233233
'shareType' => IShare::TYPE_EMAIL,
@@ -237,8 +237,8 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
237237
} else {
238238
$result['wide'][] = [
239239
'label' => $displayName,
240-
'uuid' => $contact['UID'],
241-
'name' => $contact['FN'],
240+
'uuid' => $contact['UID'] ?? $emailAddress,
241+
'name' => $contact['FN'] ?? $displayName,
242242
'type' => $emailAddressType ?? '',
243243
'value' => [
244244
'shareType' => IShare::TYPE_EMAIL,

0 commit comments

Comments
 (0)