Skip to content
Quiet Social

Laravel events

This documentation is translated from French. Should the two versions differ, the French version prevails.

The package raises eight Laravel events, all in QuietSocial\Social\Events: three come from the synchronisation of your models, five from Quiet Social webhooks. Listen to them to warn an author or react to a publication.

Synchronisation events

Event Raised when Properties
SocialPostRejected The API, or the package itself, refused the post a model describes: too long for a network, missing image for Instagram, relative link, cover not found… Not retried; the same post is not sent again, the next change is. model, error (ValidationFailed), link (rejected, errors in last_error)
SocialPostOutdated The model changed after its post left: nothing is sent to correct it. model, link
SocialPostFailed A synchronisation failed for a reason retrying will not fix (credentials refused, a missing right, a configuration error), or a temporary failure outlasted every attempt. The exception is also reported through report(). model (null if deleted), error, link (or null)

They are raised once the lock of the model is released, each on its own: a listener may save the model, and a listener that throws is reported without losing the others. SocialPostRejected is raised only once per error: the same refusal is not recorded again on every save.

use Illuminate\Support\Facades\Event;
use QuietSocial\Social\Events\SocialPostOutdated;

Event::listen(function (SocialPostOutdated $event): void {
    // The article changed after its post left: warn its author.
});

Webhook events

Event Notification Properties
RemotePublicationCreated publication.created publication, payload, id(), reference()
RemotePublicationPublished publication.published same
RemotePublicationFailed publication.failed or publication.partially_published: read publication['status'] to tell them apart same
RemotePublicationCancelled publication.cancelled: in the panel, through the API, or by this package same
RemoteConnectionRequiresReconnect social_connection.requires_reconnect: nothing will be published on its destinations until someone reconnects it in the panel payload

publication is the publication as the API returns it, payload the whole body of the notification. id() returns its pub_… identifier, reference() its external_reference, {morph class}:{key} for a post of the package. The local link is updated before the event is raised: a listener that reads the model again finds the announced status there.

These events are only raised if the webhook route is configured, and for the events the endpoint is subscribed to in the panel.