diff --git a/CHANGELOG.md b/CHANGELOG.md index 82dc1b9..3442fc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ v2.0 - Fix FLEXIAPI-355 Add withoutGlobalScope() to the Account ContactVcardList resolver - Fix FLEXIAPI-354 Fix contact deletion - Fix FLEXIAPI-360 Add rules on some jobs to only run them in the Gitlab pipeline when needed +- Fix FLEXIAPI-362 Return an empty object and not an empty array in the vcards-storage index endpoint to prevent some parsing issues in the clients v1.6 ---- diff --git a/flexiapi/app/Http/Controllers/Api/Admin/VcardsStorageController.php b/flexiapi/app/Http/Controllers/Api/Admin/VcardsStorageController.php index 6e06b98..fe91ca3 100644 --- a/flexiapi/app/Http/Controllers/Api/Admin/VcardsStorageController.php +++ b/flexiapi/app/Http/Controllers/Api/Admin/VcardsStorageController.php @@ -26,12 +26,14 @@ use App\VcardStorage; use Illuminate\Http\Request; use Sabre\VObject; +use stdClass; class VcardsStorageController extends Controller { public function index(int $accountId) { - return Account::findOrFail($accountId)->vcardsStorage()->get()->keyBy('uuid'); + $list = Account::findOrFail($accountId)->vcardsStorage()->get()->keyBy('uuid'); + return $list->isEmpty() ? new stdClass : $list; } public function show(int $accountId, string $uuid) diff --git a/flexiapi/tests/Feature/ApiAccountVcardsStorageTest.php b/flexiapi/tests/Feature/ApiAccountVcardsStorageTest.php index d8afded..f0211f9 100644 --- a/flexiapi/tests/Feature/ApiAccountVcardsStorageTest.php +++ b/flexiapi/tests/Feature/ApiAccountVcardsStorageTest.php @@ -62,6 +62,12 @@ UID:' . $uid3 . ' END:VCARD '; + // Empty + $this->keyAuthenticated($account) + ->get($this->route) + ->assertStatus(200) + ->assertSee('{}'); + // Missing vcard $this->keyAuthenticated($account) ->json($this->method, $this->route, [