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 2d611a1e33
commit 058d253dbc
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-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
----

View file

@ -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)

View file

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