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 14, 2024
1 parent 6202619 commit 16d93ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Controller/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function searchAttendee(string $search):JSONResponse {

$contacts = [];
foreach ($result as $r) {
if (!$this->contactsService->hasEmail($r) || $this->contactsService->isSystemBook($r)) {
if ($this->contactsService->isSystemBook($r) || !$this->contactsService->hasEmail($r)) {
continue;
}
$name = $this->contactsService->getNameFromContact($r);
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/ContactsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function filterGroupsWithCount(array $groups, string $search): array {
$categories = [];
foreach ($groups as $group) {
$categories[] = array_filter(explode(',', $group['CATEGORIES']), static function ($cat) use ($search) {
return str_contains(strtolower($cat), $search);
return str_contains(strtolower($cat), strtolower($search));
});
}
return array_count_values(array_merge(...$categories));
Expand Down
10 changes: 9 additions & 1 deletion tests/php/unit/Controller/ContactControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace OCA\Calendar\Controller;

use ChristophWurst\Nextcloud\Testing\TestCase;
use OCA\Calendar\Service\ContactsService;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Contacts\IManager;
Expand All @@ -30,6 +31,7 @@ class ContactControllerTest extends TestCase {

/** @var IUserManager|MockObject */
private $userManager;
private ContactsService|MockObject $service;

/** @var ContactController */
protected $controller;
Expand All @@ -42,8 +44,14 @@ protected function setUp():void {
$this->manager = $this->createMock(IManager::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->service = $this->createMock(ContactsService::class);
$this->controller = new ContactController($this->appName,
$this->request, $this->manager, $this->appManager, $this->userManager);
$this->request,
$this->manager,
$this->appManager,
$this->userManager,
$this->service
);
}

public function testSearchLocationDisabled():void {
Expand Down

0 comments on commit 16d93ed

Please sign in to comment.