class WebhookController implements RequestHandlerInterface

Receives inbound delivery-event webhooks (bounces, complaints) from the active mail driver's provider, verifies them, and dispatches the corresponding Flarum event so listeners can react.

Methods

__construct( MailWebhooks $webhooks, SettingsRepositoryInterface $settings, UserRepository $users, Dispatcher $events, LoggerInterface $logger, ConnectionInterface $database, Repository $cache)

No description

ResponseInterface
handle( ServerRequestInterface $request)

No description

ResponseInterface
refuse( ServerRequestInterface $request, int $status, string $reason)

No description

void
handleEvent( HandlesWebhooks $driver, object $event)

No description

recipients(string $email)

No description

void
dispatchOnce( HandlesWebhooks $driver, MailerDeliveryEvent| MailerEngagementEvent $remote, EmailBounced| EmailComplained $event)

No description

Request
toSymfonyRequest( ServerRequestInterface $request)

Build the Symfony HttpFoundation request the driver's parser expects, preserving the method, headers and raw body needed for signature verification. Avoids pulling in the PSR-7 <-> Symfony bridge dependency.

string
rawBody( ServerRequestInterface $request)

The raw request body as a JSON string. Reads the body stream directly, but falls back to re-encoding the already-parsed body if an upstream middleware has consumed the (non-rewindable) stream first — which is what happens inside Flarum's middleware stack.

Details

__construct( MailWebhooks $webhooks, SettingsRepositoryInterface $settings, UserRepository $users, Dispatcher $events, LoggerInterface $logger, ConnectionInterface $database, Repository $cache)

Parameters

MailWebhooks $webhooks
SettingsRepositoryInterface $settings
UserRepository $users
Dispatcher $events
LoggerInterface $logger
ConnectionInterface $database
Repository $cache

ResponseInterface handle( ServerRequestInterface $request)

Parameters

ServerRequestInterface $request

Return Value

ResponseInterface

protected ResponseInterface refuse( ServerRequestInterface $request, int $status, string $reason)

Parameters

ServerRequestInterface $request
int $status
string $reason

Return Value

ResponseInterface

protected void handleEvent( HandlesWebhooks $driver, object $event)

Parameters

HandlesWebhooks $driver
object $event

Return Value

void

protected Collection recipients(string $email)

Parameters

string $email

Return Value

Collection

protected void dispatchOnce( HandlesWebhooks $driver, MailerDeliveryEvent| MailerEngagementEvent $remote, EmailBounced| EmailComplained $event)

Parameters

HandlesWebhooks $driver
MailerDeliveryEvent| MailerEngagementEvent $remote
EmailBounced| EmailComplained $event

Return Value

void

protected Request toSymfonyRequest( ServerRequestInterface $request)

Build the Symfony HttpFoundation request the driver's parser expects, preserving the method, headers and raw body needed for signature verification. Avoids pulling in the PSR-7 <-> Symfony bridge dependency.

Parameters

ServerRequestInterface $request

Return Value

Request

protected string rawBody( ServerRequestInterface $request)

The raw request body as a JSON string. Reads the body stream directly, but falls back to re-encoding the already-parsed body if an upstream middleware has consumed the (non-rewindable) stream first — which is what happens inside Flarum's middleware stack.

Parameters

ServerRequestInterface $request

Return Value

string