feat: only handle unsubscribe events for configured list ids

This commit is contained in:
Björn Fromme
2026-05-13 08:30:22 +02:00
parent 132dfc6860
commit 7dfbc06bd1
3 changed files with 82 additions and 3 deletions
@@ -15,9 +15,13 @@ use Symfony\Component\Routing\Attribute\Route;
final class MailjetNewsletterWebhookController extends AbstractController
{
/**
* @param array<int, string> $mailjetLists
*/
public function __construct(
private readonly MessageBusInterface $messageBus,
private readonly LoggerInterface $logger,
private readonly array $mailjetLists = [],
) {
}
@@ -98,6 +102,15 @@ final class MailjetNewsletterWebhookController extends AbstractController
return null;
}
if (false === $this->isHandledListId($mailjetListId)) {
$this->logger->info('Ignored Mailjet newsletter webhook event for unconfigured list', [
'email' => $email,
'mailjet_list_id' => $mailjetListId,
]);
return null;
}
return new MailjetNewsletterEventMessage(
email: $email,
mailjetListId: $mailjetListId,
@@ -126,6 +139,11 @@ final class MailjetNewsletterWebhookController extends AbstractController
return null;
}
private function isHandledListId(int $mailjetListId): bool
{
return array_key_exists($mailjetListId, $this->mailjetLists);
}
/**
* @param array<string, mixed> $payload
*/