chore: checkpoint before block builder refactor

This commit is contained in:
2026-04-03 23:03:09 +02:00
parent 330950cc6e
commit 4f3fefca5c
14 changed files with 315 additions and 99 deletions

View File

@@ -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'],
];

View File

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

View File

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