File: /home/xedaptot/ai.naniguide.com/app/Providers/EventServiceProvider.php
<?php
namespace App\Providers;
use App\Listeners\SendingServerWebhooks\ConfirmSnsSubscription;
use App\Listeners\SendingServerWebhooks\RecordBounce;
use App\Listeners\SendingServerWebhooks\RecordComplaint;
use App\SendingServers\Webhooks\BounceReceived;
use App\SendingServers\Webhooks\ComplaintReceived;
use App\SendingServers\Webhooks\WebhookHandshake;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* Auto-discovery (`shouldDiscoverEvents`) is disabled at the bootstrap
* level via `bootstrap/app.php` → `withEvents(discover: false)`. That's
* the layer Laravel 12 actually checks; setting `$shouldDiscoverEvents`
* here in the subclass is a no-op because the parent's
* `shouldDiscoverEvents()` only honors the static when the instance is
* the BASE class itself (`get_class($this) === __CLASS__`).
*
* @var array
*/
protected $listen = [
'App\Events\CampaignUpdated' => [
'App\Listeners\CampaignUpdatedListener',
],
'App\Events\MailListUpdated' => [
'App\Listeners\MailListUpdatedListener',
],
'App\Events\UserUpdated' => [
'App\Listeners\UserUpdatedListener',
],
'App\Events\CronJobExecuted' => [
'App\Listeners\CronJobExecutedListener',
],
'App\Events\AdminLoggedIn' => [
'App\Listeners\AdminLoggedInListener',
],
'App\Events\MailListImported' => [
'App\Listeners\TriggerAutomationForImportedContacts',
],
'App\Events\MailListUnsubscription' => [
// R6: GDPR cascade — remove the unsubscribed email from every
// ad audience owned by the same customer. Gated by
// `ads.compliance.gdpr_remove_on_unsubscribe` inside the listener.
'App\Listeners\Ads\SubscriberOptOutListener',
// R13: customer-defined automation rules with
// trigger_event=email_unsubscribe fire here. Gated by
// `ads.automation.enabled` inside the listener; per-rule
// throttle (10 actions/min default) applied before dispatch.
'App\Listeners\Ads\RunAutomationOnUnsubscribe',
],
Registered::class => [
SendEmailVerificationNotification::class,
],
// Sending-server vendor webhook → side effect listeners.
// Drivers parse vendor payloads → yield these vendor-neutral events.
// See docs/sending-server-polymorphism/SENDING-SERVER-POLYMORPHISM-COMPREHENSIVE-DESIGN.md.
BounceReceived::class => [RecordBounce::class],
ComplaintReceived::class => [RecordComplaint::class],
WebhookHandshake::class => [ConfirmSnsSubscription::class],
// DeliveryConfirmed::class + IgnorableWebhookEvent::class — no listener (parity: legacy didn't either).
];
/**
* Subscriber-pattern listeners — each class owns multi-event registration
* via its own `subscribe(Dispatcher $events)` method.
*
* IMPORTANT: these MUST be registered explicitly. Previously they were
* picked up implicitly by Laravel's event auto-discovery (which scans
* for `handle*(EventClass)` methods). When we disabled auto-discovery
* via `bootstrap/app.php` → `withEvents(discover: false)` to fix the
* duplicate-listener bug, this commented-out `$subscribe` array silently
* broke 3 features (automation triggers, list-owner subscribe/unsubscribe
* notification email, subscriber welcome/goodbye email). Uncommented and
* kept tested; do not re-comment.
*/
protected $subscribe = [
'App\Listeners\TriggerAutomation',
'App\Listeners\SendListNotificationToOwner',
'App\Listeners\SendListNotificationToSubscriber',
];
/**
* Register any events for your application.
*/
public function boot()
{
parent::boot();
}
}