Fix #165 Remove for now text/vcard header constraint

This commit is contained in:
Timothée Jaussoin 2024-04-25 09:05:05 +00:00
parent debf668e77
commit 911862870c
4 changed files with 18 additions and 16 deletions

View file

@ -2,6 +2,7 @@
v1.5 v1.5
---- ----
- Fix FLEXIAPI-165 Remove for now text/vcard header constraint
- Fix FLEXIAPI-164 Add vcards-storage endpoints - Fix FLEXIAPI-164 Add vcards-storage endpoints
- Fix FLEXIAPI-162 Drop the aliases table and migrate the data to the phone column - 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 - Fix FLEXIAPI-161 Complete the Dictionary tests to cover the collection accessor

View file

@ -9,7 +9,7 @@ class VcardsStorageController extends Controller
{ {
public function index(Request $request) public function index(Request $request)
{ {
if ($this->vcardRequested($request)) { //if ($this->vcardRequested($request)) {
$vcards = ''; $vcards = '';
foreach ($request->user()->vcardsStorage()->get() as $vcard) { foreach ($request->user()->vcardsStorage()->get() as $vcard) {
@ -17,21 +17,21 @@ class VcardsStorageController extends Controller
} }
return $vcards; return $vcards;
} /*}
abort(404); abort(404);*/
} }
public function show(Request $request, string $uuid) public function show(Request $request, string $uuid)
{ {
return ($this->vcardRequested($request)) return /*($this->vcardRequested($request))
? $request->user()->vcardsStorage()->where('uuid', $uuid)->firstOrFail()->vcard ?*/ $request->user()->vcardsStorage()->where('uuid', $uuid)->firstOrFail()->vcard
: abort(404); /*: abort(404)*/;
} }
private function vcardRequested(Request $request): bool /*private function vcardRequested(Request $request): bool
{ {
return $request->hasHeader('content-type') == 'text/vcard' return $request->hasHeader('content-type') == 'text/vcard'
&& $request->hasHeader('accept') == 'text/vcard'; && $request->hasHeader('accept') == 'text/vcard';
} }*/
} }

View file

@ -763,12 +763,13 @@ Return a specific user authenticated contact, in [vCard 4.0 format](https://data
## vCards Storage ## vCards Storage
<!---
The following headers are mandatory to access the following endpoints: The following headers are mandatory to access the following endpoints:
``` ```
> content-type: text/vcard > content-type: text/vcard
> accept: text/vcard > accept: text/vcard
``` ```
--->
### `GET /vcards-storage` ### `GET /vcards-storage`

View file

@ -40,7 +40,7 @@ FN:Simone Perreault
UID:' . $uid . ' UID:' . $uid . '
END:VCARD END:VCARD
'; ';
$uid2 = 'urn:uuid: a5b33443-687c-4d19-bdd0-b30cf76bf96d'; $uid2 = 'urn:uuid:a5b33443-687c-4d19-bdd0-b30cf76bf96d';
$secondVcard = $secondVcard =
'BEGIN:VCARD 'BEGIN:VCARD
VERSION:4.0 VERSION:4.0
@ -136,25 +136,25 @@ END:VCARD'
]); ]);
// Vcard format endpoints // Vcard format endpoints
$this->keyAuthenticated($account) /*$this->keyAuthenticated($account)
->get('vcards-storage') ->get('vcards-storage')
->assertStatus(404); ->assertStatus(404);*/
$this->keyAuthenticated($account) $this->keyAuthenticated($account)
->withHeaders([ /*->withHeaders([
'content-type' => 'text/vcard', 'content-type' => 'text/vcard',
'accept' => 'text/vcard', 'accept' => 'text/vcard',
]) ])*/
->get('vcards-storage') ->get('vcards-storage')
->assertStatus(200) ->assertStatus(200)
->assertSee($lastVcard) ->assertSee($lastVcard)
->assertSee($secondVcard); ->assertSee($secondVcard);
$this->keyAuthenticated($account) $this->keyAuthenticated($account)
->withHeaders([ /*->withHeaders([
'content-type' => 'text/vcard', 'content-type' => 'text/vcard',
'accept' => 'text/vcard', 'accept' => 'text/vcard',
]) ])*/
->get('vcards-storage/' . $uid) ->get('vcards-storage/' . $uid)
->assertStatus(200) ->assertStatus(200)
->assertSee($lastVcard); ->assertSee($lastVcard);