feat: only handle unsubscribe events for configured list ids
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user