add the current location of the user as API point + add it in the activity location list

This commit is contained in:
nobohan
2021-12-13 11:04:10 +01:00
parent 1e99ca2ca5
commit 82c027fe2a
5 changed files with 90 additions and 36 deletions

View File

@@ -37,4 +37,25 @@ class UserApiController extends ApiController
['groups' => ['read']]
);
}
/**
* @Route(
* "/api/1.0/main/user-current-location.{_format}",
* name="chill_main_user_current_location",
* requirements={
* "_format": "json"
* }
* )
*
* @param mixed $_format
*/
public function currentLocation($_format): JsonResponse
{
return $this->json(
$this->getUser()->getCurrentLocation(),
JsonResponse::HTTP_OK,
[],
['groups' => ['read']]
);
}
}

View File

@@ -61,6 +61,14 @@ final class UserApiControllerTest extends WebTestCase
$client->request(Request::METHOD_GET, '/api/1.0/main/whoami.json');
$this->assertResponseIsSuccessful();
}
public function testUserCurrentLocation()
{
$client = $this->getClientAuthenticated();
$client->request(Request::METHOD_GET, '/api/1.0/main/user-current-location.json');
$this->assertResponseIsSuccessful();
}
}

View File

@@ -546,6 +546,14 @@ paths:
responses:
200:
description: "ok"
/1.0/main/user-current-location.json:
get:
tags:
- user
summary: Return the current location of the currently authenticated user
responses:
200:
description: "ok"
/1.0/main/user/{id}.json:
get:
tags: