chore: checkpoint before block builder refactor
This commit is contained in:
@@ -41,9 +41,7 @@ class UpdateMailwizzConfigRequest extends FormRequest
|
||||
'field_email' => ['required', 'string', 'max:255'],
|
||||
'field_first_name' => ['required', 'string', 'max:255'],
|
||||
'field_last_name' => ['required', 'string', 'max:255'],
|
||||
'field_phone' => $page->phone_enabled
|
||||
? ['required', 'string', 'max:255']
|
||||
: ['nullable', 'string', 'max:255'],
|
||||
'field_phone' => ['nullable', 'string', 'max:255'],
|
||||
'tag_field' => ['required', 'string', 'max:255'],
|
||||
'tag_value' => ['required', 'string', 'max:255'],
|
||||
];
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Requests;
|
||||
|
||||
use App\Models\PreregistrationPage;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Email;
|
||||
|
||||
class SubscribePublicPageRequest extends FormRequest
|
||||
{
|
||||
@@ -22,13 +23,28 @@ class SubscribePublicPageRequest extends FormRequest
|
||||
/** @var PreregistrationPage $page */
|
||||
$page = $this->route('publicPage');
|
||||
|
||||
$emailRule = (new Email)
|
||||
->rfcCompliant()
|
||||
->preventSpoofing();
|
||||
|
||||
return [
|
||||
'first_name' => ['required', 'string', 'max:255'],
|
||||
'last_name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'email', 'max:255'],
|
||||
'email' => ['required', 'string', 'max:255', $emailRule],
|
||||
'phone' => $page->phone_enabled
|
||||
? ['required', 'string', 'max:20']
|
||||
: ['nullable', 'string', 'max:20'],
|
||||
? ['nullable', 'string', 'regex:/^[0-9]{8,15}$/']
|
||||
: ['nullable', 'string', 'max:255'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'email' => __('Please enter a valid email address.'),
|
||||
'phone.regex' => __('Please enter a valid phone number (8–15 digits).'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -53,5 +69,18 @@ class SubscribePublicPageRequest extends FormRequest
|
||||
'email' => strtolower(trim($email)),
|
||||
]);
|
||||
}
|
||||
|
||||
/** @var PreregistrationPage $page */
|
||||
$page = $this->route('publicPage');
|
||||
$phone = $this->input('phone');
|
||||
if (! $page->phone_enabled) {
|
||||
$this->merge(['phone' => null]);
|
||||
|
||||
return;
|
||||
}
|
||||
if (is_string($phone)) {
|
||||
$digits = preg_replace('/\D+/', '', $phone);
|
||||
$this->merge(['phone' => $digits === '' ? null : $digits]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class SyncSubscriberToMailwizz implements ShouldBeUnique, ShouldQueue
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $this->configIsComplete($config, $page->phone_enabled)) {
|
||||
if (! $this->configIsComplete($config)) {
|
||||
Log::warning('SyncSubscriberToMailwizz: incomplete Mailwizz config', [
|
||||
'subscriber_id' => $subscriber->id,
|
||||
'page_id' => $page->id,
|
||||
@@ -106,16 +106,12 @@ class SyncSubscriberToMailwizz implements ShouldBeUnique, ShouldQueue
|
||||
]);
|
||||
}
|
||||
|
||||
private function configIsComplete(MailwizzConfig $config, bool $phoneEnabled): bool
|
||||
private function configIsComplete(MailwizzConfig $config): bool
|
||||
{
|
||||
if ($config->list_uid === '' || $config->field_email === '' || $config->field_first_name === '' || $config->field_last_name === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($phoneEnabled && ($config->field_phone === null || $config->field_phone === '')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($config->tag_field === null || $config->tag_field === '' || $config->tag_value === null || $config->tag_value === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user