1
0
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:
Baptiste Lemoine 2020-04-21 18:11:39 +02:00
parent ed59c30961
commit 2c609e2f09

View File

@ -325,17 +325,28 @@ class PollController extends FramadateController {
* )
*/
public function checkSlugIsUniqueAction( string $slug ) {
$emPoll = $this->getDoctrine()->getRepository( Poll::class );
$found = $emPoll->findOneByCustomUrl( $slug );
$emPoll = $this->getDoctrine()->getRepository( Poll::class );
$found = $emPoll->findOneByCustomUrl( $slug );
$elaborated_message_version = false;
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( [
'message' => ' NO, this slug is already taken on this Framadate instance ',
'data' => [
'slug' => $slug,
],
],
403 );
200 );
}
if ( ! $elaborated_message_version ) {
return $this->json( false,
404 );
}
return $this->json( [
@ -344,7 +355,7 @@ class PollController extends FramadateController {
'slug' => $slug,
],
],
200 );
404 );
}