@@ -39,7 +39,7 @@ public function __construct(
3939
4040 #[Route('/subscribers ' , name: 'create_subscriber ' , methods: ['POST ' ])]
4141 #[OA \Post(
42- path: '/subscriber ' ,
42+ path: '/subscribers ' ,
4343 description: 'Creates a new subscriber (if there is no subscriber with the given email address yet). ' ,
4444 summary: 'Create a subscriber ' ,
4545 requestBody: new OA \RequestBody (
@@ -49,10 +49,8 @@ public function __construct(
4949 required: ['email ' ],
5050 properties: [
5151 new OA \Property (property: 'email ' , type: 'string ' , format: 'string ' , example: 'admin@example.com ' ),
52- new OA \Property (property: 'confirmed ' , type: 'boolean ' , example: false ),
53- new OA \Property (property: 'blacklisted ' , type: 'boolean ' , example: false ),
52+ new OA \Property (property: 'request_confirmation ' , type: 'boolean ' , example: false ),
5453 new OA \Property (property: 'html_email ' , type: 'boolean ' , example: false ),
55- new OA \Property (property: 'disabled ' , type: 'boolean ' , example: false )
5654 ]
5755 )
5856 ),
@@ -140,13 +138,14 @@ public function postAction(Request $request, SerializerInterface $serializer): J
140138 if ($ this ->subscriberRepository ->findOneByEmail ($ email ) !== null ) {
141139 throw new ConflictHttpException ('This resource already exists. ' , null , 1513439108 );
142140 }
141+ $ confirmed = (bool )$ data ->get ('request_confirmation ' , true );
143142 // @phpstan-ignore-next-line
144143 $ subscriber = new Subscriber ();
145144 $ subscriber ->setEmail ($ email );
146- $ subscriber ->setConfirmed (( bool ) $ data -> get ( ' confirmed ' , false ) );
147- $ subscriber ->setBlacklisted (( bool ) $ data -> get ( ' blacklisted ' , false ) );
145+ $ subscriber ->setConfirmed (! $ confirmed );
146+ $ subscriber ->setBlacklisted (false );
148147 $ subscriber ->setHtmlEmail ((bool )$ data ->get ('html_email ' , true ));
149- $ subscriber ->setDisabled (( bool ) $ data -> get ( ' disabled ' , false ) );
148+ $ subscriber ->setDisabled (false );
150149
151150 $ this ->subscriberRepository ->save ($ subscriber );
152151
@@ -173,7 +172,7 @@ private function validateSubscriber(Request $request): void
173172 $ invalidFields [] = 'email ' ;
174173 }
175174
176- $ booleanFields = ['confirmed ' , 'blacklisted ' , ' html_email ' , ' disabled ' ];
175+ $ booleanFields = ['request_confirmation ' , 'html_email ' ];
177176 foreach ($ booleanFields as $ fieldKey ) {
178177 if ($ request ->getPayload ()->get ($ fieldKey ) !== null
179178 && !is_bool ($ request ->getPayload ()->get ($ fieldKey ))
0 commit comments