mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
change slug answers
This commit is contained in:
parent
ed59c30961
commit
2c609e2f09
@ -325,17 +325,28 @@ class PollController extends FramadateController {
|
|||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function checkSlugIsUniqueAction( string $slug ) {
|
public function checkSlugIsUniqueAction( string $slug ) {
|
||||||
$emPoll = $this->getDoctrine()->getRepository( Poll::class );
|
$emPoll = $this->getDoctrine()->getRepository( Poll::class );
|
||||||
$found = $emPoll->findOneByCustomUrl( $slug );
|
$found = $emPoll->findOneByCustomUrl( $slug );
|
||||||
|
$elaborated_message_version = false;
|
||||||
|
|
||||||
if ( $found ) {
|
if ( $found ) {
|
||||||
// we should not find an other poll
|
if ( ! $elaborated_message_version ) {
|
||||||
|
return $this->json( true,
|
||||||
|
200 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// we should use an other slug
|
||||||
return $this->json( [
|
return $this->json( [
|
||||||
'message' => ' NO, this slug is already taken on this Framadate instance ',
|
'message' => ' NO, this slug is already taken on this Framadate instance ',
|
||||||
'data' => [
|
'data' => [
|
||||||
'slug' => $slug,
|
'slug' => $slug,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
403 );
|
200 );
|
||||||
|
}
|
||||||
|
if ( ! $elaborated_message_version ) {
|
||||||
|
return $this->json( false,
|
||||||
|
404 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->json( [
|
return $this->json( [
|
||||||
@ -344,7 +355,7 @@ class PollController extends FramadateController {
|
|||||||
'slug' => $slug,
|
'slug' => $slug,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
200 );
|
404 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user