Skip to content

Commit

Permalink
fixup! feat: allow inviting contact groups
Browse files Browse the repository at this point in the history
  • Loading branch information
miaulalala committed Oct 17, 2024
1 parent 8967750 commit 0ec05ad
Show file tree
Hide file tree
Showing 3 changed files with 322 additions and 122 deletions.
14 changes: 4 additions & 10 deletions lib/Controller/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,7 @@ public function searchLocation(string $search): JSONResponse {

$name = $this->contactsService->getNameFromContact($r);
$photo = $this->contactsService->getPhotoUri($r);

if (\is_string($r['ADR'])) {
$r['ADR'] = [$r['ADR']];
}
$addresses = [];
foreach ($r['ADR'] as $address) {
$addresses[] = trim(preg_replace("/\n+/", "\n", str_replace(';', "\n", $address)));
}
$addresses = $this->contactsService->getAddress($r);

$contacts[] = [
'name' => $name,
Expand Down Expand Up @@ -263,7 +256,7 @@ public function searchPhoto(string $search):JSONResponse {
if (!$this->contactsService->hasEmail($r) || $this->contactsService->isSystemBook($r)) {
continue;
}
$email = $this->contactsService->getEmail($r['EMAIL']);
$email = $this->contactsService->getEmail($r);

$match = false;
foreach ($email as $e) {
Expand All @@ -276,7 +269,7 @@ public function searchPhoto(string $search):JSONResponse {
continue;
}

$photo = $this->contactsService->getPhotoUri($r['PHOTO']);
$photo = $this->contactsService->getPhotoUri($r);
if ($photo === null) {
continue;
}
Expand All @@ -291,4 +284,5 @@ public function searchPhoto(string $search):JSONResponse {

return new JSONResponse([], Http::STATUS_NOT_FOUND);
}

}
15 changes: 15 additions & 0 deletions lib/Service/ContactsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,19 @@ public function filterGroupsWithCount(array $groups, string $search): array {
}
return array_count_values(array_merge(...$categories));
}

/**
* @param array $contact
* @return array
*/
public function getAddress(array $contact): array {
if (\is_string($contact['ADR'])) {
$contact['ADR'] = [$contact['ADR']];
}
$addresses = [];
foreach ($contact['ADR'] as $address) {
$addresses[] = trim(preg_replace("/\n+/", "\n", str_replace(';', "\n", $address)));
}
return $addresses;
}
}
Loading

0 comments on commit 0ec05ad

Please sign in to comment.