feat(api): add spam content detection for forms

- Add SpamDetectionService to detect gibberish/random text
- Detect excessive consonants, low vowel ratio, mixed case patterns
- Detect repeated characters and extremely long words
- Validate names look realistic (start with letter, have vowels)
- Cross-validate multiple suspicious fields
- Integrate with ContactFormAjaxHandler and NewsletterAjaxHandler
- Log blocked attempts to debug.log

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
FrankZamora
2026-01-09 09:46:47 -06:00
parent a93e54e1b8
commit eb50c80297
4 changed files with 468 additions and 6 deletions

View File

@@ -146,17 +146,22 @@ try {
// Obtener servicio de validacion reCAPTCHA para inyectar en handlers
$recaptchaService = $container->getRecaptchaValidationService();
// Crear servicio de deteccion de spam para validar contenido
$spamDetectionService = new \ROITheme\Shared\Application\Services\SpamDetectionService();
// Crear y registrar el handler AJAX para el Contact Form (público)
$contactFormAjaxHandler = new \ROITheme\Public\ContactForm\Infrastructure\Api\WordPress\ContactFormAjaxHandler(
$container->getComponentSettingsRepository(),
$recaptchaService
$recaptchaService,
$spamDetectionService
);
$contactFormAjaxHandler->register();
// Crear y registrar el handler AJAX para Newsletter (público)
$newsletterAjaxHandler = new \ROITheme\Public\Footer\Infrastructure\Api\WordPress\NewsletterAjaxHandler(
$container->getComponentSettingsRepository(),
$recaptchaService
$recaptchaService,
$spamDetectionService
);
$newsletterAjaxHandler->register();