@@ -39,7 +39,7 @@ public function __construct(
39
39
40
40
#[Route('/subscribers ' , name: 'create_subscriber ' , methods: ['POST ' ])]
41
41
#[OA \Post(
42
- path: '/subscriber ' ,
42
+ path: '/subscribers ' ,
43
43
description: 'Creates a new subscriber (if there is no subscriber with the given email address yet). ' ,
44
44
summary: 'Create a subscriber ' ,
45
45
requestBody: new OA \RequestBody (
@@ -49,10 +49,8 @@ public function __construct(
49
49
required: ['email ' ],
50
50
properties: [
51
51
new OA \
Property (property:
'email ' , type:
'string ' , format:
'string ' , example:
'[email protected] ' ),
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 ),
54
53
new OA \Property (property: 'html_email ' , type: 'boolean ' , example: false ),
55
- new OA \Property (property: 'disabled ' , type: 'boolean ' , example: false )
56
54
]
57
55
)
58
56
),
@@ -140,13 +138,14 @@ public function postAction(Request $request, SerializerInterface $serializer): J
140
138
if ($ this ->subscriberRepository ->findOneByEmail ($ email ) !== null ) {
141
139
throw new ConflictHttpException ('This resource already exists. ' , null , 1513439108 );
142
140
}
141
+ $ confirmed = (bool )$ data ->get ('request_confirmation ' , true );
143
142
// @phpstan-ignore-next-line
144
143
$ subscriber = new Subscriber ();
145
144
$ 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 );
148
147
$ subscriber ->setHtmlEmail ((bool )$ data ->get ('html_email ' , true ));
149
- $ subscriber ->setDisabled (( bool ) $ data -> get ( ' disabled ' , false ) );
148
+ $ subscriber ->setDisabled (false );
150
149
151
150
$ this ->subscriberRepository ->save ($ subscriber );
152
151
@@ -173,7 +172,7 @@ private function validateSubscriber(Request $request): void
173
172
$ invalidFields [] = 'email ' ;
174
173
}
175
174
176
- $ booleanFields = ['confirmed ' , 'blacklisted ' , ' html_email ' , ' disabled ' ];
175
+ $ booleanFields = ['request_confirmation ' , 'html_email ' ];
177
176
foreach ($ booleanFields as $ fieldKey ) {
178
177
if ($ request ->getPayload ()->get ($ fieldKey ) !== null
179
178
&& !is_bool ($ request ->getPayload ()->get ($ fieldKey ))
0 commit comments