diff --git a/src/Controller/PollController.php b/src/Controller/PollController.php index d296287..4cf9ee5 100644 --- a/src/Controller/PollController.php +++ b/src/Controller/PollController.php @@ -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 ); }