From 911862870cc359ea98819dfe8be47435efc27820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Jaussoin?= Date: Thu, 25 Apr 2024 09:05:05 +0000 Subject: [PATCH] Fix #165 Remove for now text/vcard header constraint --- CHANGELOG.md | 1 + .../Account/VcardsStorageController.php | 16 ++++++++-------- .../views/api/documentation_markdown.blade.php | 3 ++- .../Feature/ApiAccountVcardsStorageTest.php | 14 +++++++------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6becc64..8b6e273 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ v1.5 ---- +- Fix FLEXIAPI-165 Remove for now text/vcard header constraint - Fix FLEXIAPI-164 Add vcards-storage endpoints - Fix FLEXIAPI-162 Drop the aliases table and migrate the data to the phone column - Fix FLEXIAPI-161 Complete the Dictionary tests to cover the collection accessor diff --git a/flexiapi/app/Http/Controllers/Account/VcardsStorageController.php b/flexiapi/app/Http/Controllers/Account/VcardsStorageController.php index b9f7706..c84eded 100644 --- a/flexiapi/app/Http/Controllers/Account/VcardsStorageController.php +++ b/flexiapi/app/Http/Controllers/Account/VcardsStorageController.php @@ -9,7 +9,7 @@ class VcardsStorageController extends Controller { public function index(Request $request) { - if ($this->vcardRequested($request)) { + //if ($this->vcardRequested($request)) { $vcards = ''; foreach ($request->user()->vcardsStorage()->get() as $vcard) { @@ -17,21 +17,21 @@ class VcardsStorageController extends Controller } return $vcards; - } + /*} - abort(404); + abort(404);*/ } public function show(Request $request, string $uuid) { - return ($this->vcardRequested($request)) - ? $request->user()->vcardsStorage()->where('uuid', $uuid)->firstOrFail()->vcard - : abort(404); + return /*($this->vcardRequested($request)) + ?*/ $request->user()->vcardsStorage()->where('uuid', $uuid)->firstOrFail()->vcard + /*: abort(404)*/; } - private function vcardRequested(Request $request): bool + /*private function vcardRequested(Request $request): bool { return $request->hasHeader('content-type') == 'text/vcard' && $request->hasHeader('accept') == 'text/vcard'; - } + }*/ } diff --git a/flexiapi/resources/views/api/documentation_markdown.blade.php b/flexiapi/resources/views/api/documentation_markdown.blade.php index 3c28ce1..393d2a1 100644 --- a/flexiapi/resources/views/api/documentation_markdown.blade.php +++ b/flexiapi/resources/views/api/documentation_markdown.blade.php @@ -763,12 +763,13 @@ Return a specific user authenticated contact, in [vCard 4.0 format](https://data ## vCards Storage + ### `GET /vcards-storage` diff --git a/flexiapi/tests/Feature/ApiAccountVcardsStorageTest.php b/flexiapi/tests/Feature/ApiAccountVcardsStorageTest.php index 7e1df75..8288574 100644 --- a/flexiapi/tests/Feature/ApiAccountVcardsStorageTest.php +++ b/flexiapi/tests/Feature/ApiAccountVcardsStorageTest.php @@ -40,7 +40,7 @@ FN:Simone Perreault UID:' . $uid . ' END:VCARD '; - $uid2 = 'urn:uuid: a5b33443-687c-4d19-bdd0-b30cf76bf96d'; + $uid2 = 'urn:uuid:a5b33443-687c-4d19-bdd0-b30cf76bf96d'; $secondVcard = 'BEGIN:VCARD VERSION:4.0 @@ -136,25 +136,25 @@ END:VCARD' ]); // Vcard format endpoints - $this->keyAuthenticated($account) + /*$this->keyAuthenticated($account) ->get('vcards-storage') - ->assertStatus(404); + ->assertStatus(404);*/ $this->keyAuthenticated($account) - ->withHeaders([ + /*->withHeaders([ 'content-type' => 'text/vcard', 'accept' => 'text/vcard', - ]) + ])*/ ->get('vcards-storage') ->assertStatus(200) ->assertSee($lastVcard) ->assertSee($secondVcard); $this->keyAuthenticated($account) - ->withHeaders([ + /*->withHeaders([ 'content-type' => 'text/vcard', 'accept' => 'text/vcard', - ]) + ])*/ ->get('vcards-storage/' . $uid) ->assertStatus(200) ->assertSee($lastVcard);