Fix FLEXIAPI-362 Return an empty object and not an empty array in the...

This commit is contained in:
Timothée Jaussoin 2025-07-22 08:18:53 +00:00
parent 1a79ae7b16
commit 507e913241
3 changed files with 10 additions and 1 deletions

View file

@ -66,6 +66,7 @@ v2.0
- Fix FLEXIAPI-355 Add withoutGlobalScope() to the Account ContactVcardList resolver - Fix FLEXIAPI-355 Add withoutGlobalScope() to the Account ContactVcardList resolver
- Fix FLEXIAPI-354 Fix contact deletion - 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-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 v1.6
---- ----

View file

@ -26,12 +26,14 @@ use App\VcardStorage;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Sabre\VObject; use Sabre\VObject;
use stdClass;
class VcardsStorageController extends Controller class VcardsStorageController extends Controller
{ {
public function index(int $accountId) 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) public function show(int $accountId, string $uuid)

View file

@ -62,6 +62,12 @@ UID:' . $uid3 . '
END:VCARD END:VCARD
'; ';
// Empty
$this->keyAuthenticated($account)
->get($this->route)
->assertStatus(200)
->assertSee('{}');
// Missing vcard // Missing vcard
$this->keyAuthenticated($account) $this->keyAuthenticated($account)
->json($this->method, $this->route, [ ->json($this->method, $this->route, [