change slug answers

This commit is contained in:
Baptiste Lemoine 2020-04-21 18:11:39 +02:00
parent ed59c30961
commit 2c609e2f09
1 changed files with 16 additions and 5 deletions

View File

@ -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 );
} }