Skip to content

Events, Broadcasting and Push ​

Overview ​

The backend has 7 event classes in app/Events and 3 listeners in app/Listeners. Four events are broadcast to the frontends over private channels for real-time badge counts, announcements and subscription state. Two events are plain server-side events with a listener. Two event classes are not used anywhere.

There is no app/Notifications folder, so Laravel Notifications are not used. Mobile push goes through the custom App\PushNotification\PushNotification class, which calls Firebase Cloud Messaging directly.

Event to listener mapping ​

Mappings are explicit in app/Providers/EventServiceProvider.php. shouldDiscoverEvents() returns false, so auto-discovery is off and a new listener must be added to $listen.

EventListenerQueuedWhat the listener does
Illuminate\Auth\Events\RegisteredIlluminate\Auth\Listeners\SendEmailVerificationNotificationnoLaravel default.
App\Events\UpdateSubscriptionRestrictionEventApp\Listeners\UpdateSubscriptionRestrictionListeneryes (ShouldQueue)Loads the workspace's SubscriptionUsers. When the dam_branding feature is off it resets WorkspaceBranding to the default colours (#070E22 / #ffffff) and is_branding = 0; when email_branding is off it sets is_branding = 0.
App\Events\GetUserSubscriptionEventApp\Listeners\GetUserSubscriptionListeneryes (ShouldQueue)handle() is empty. The useful work is the broadcast (below).
Illuminate\Mail\Events\MessageSendingApp\Listeners\ApplyWorkspaceMailToMessagenoSets the workspace From address on white-label mail, or cancels the send when white label is on without SMTP details. See Mail.
SocialiteProviders\Manager\SocialiteWasCalledSocialiteProviders\Microsoft\MicrosoftExtendSocialite@handlenoRegisters the Microsoft Socialite driver.

The queued listeners run on the default queue of the default connection, since neither sets $queue or $connection.

Event inventory ​

EventBroadcastFired fromNotes
ProjectUserNotificationBadgesEventShouldBroadcastNowSendDamEmailSystemNotificationJob, ConvertAssetsJob, AnnouncementNotification job; Web\Subscription\SubscriptionController (2), Api\v1\DigitalAssets\DamNotificationController, Api\v1\Announcement\AnnouncementController, DAM\v1\Digital\AssetProductOrderControllerPushes updated notification badge counts to an admin user.
DAMFrontendAnnouncementShouldBroadcastNowAnnouncementNotification job, DAM\v1\Digital\AnnouncementControllerPushes a new announcement badge to a portal user.
GetUserSubscriptionEventShouldBroadcastNowdam:existing-user-apply-plan commandTells the user whether a plan is now assigned. Also has a (no-op) queued listener.
UpdateSubscriptionRestrictionEventnoApi\v1\Auth\AuthController, DAM\v1\Auth\AuthController (on login, for the requested workspace)Has a broadcastOn() returning update-subscription-restriction-channel, but it does not implement ShouldBroadcast, so nothing is broadcast. Handled by its queued listener.
LogoutDealershipUserShouldBroadcastNowNo caller foundWould force-logout a portal user on logoutDealershipUser.{userId}.
PrivateEventShouldBroadcastNowNo caller foundSample event on user.{id}, payload id, name.
PubLicEventnoNo caller foundLaravel stub (channel-name).

Broadcast events ​

All four broadcast events implement ShouldBroadcastNow, so they are sent during the request or job that fires them, not through the queue. All use PrivateChannel.

EventChannelbroadcastAsPayload (broadcastWith)
ProjectUserNotificationBadgesEventprivate-user.{loginUserId}.projectBatchNotificationProjectUserNotificationBadgesEventdata (badge counts: project_badges_count, lm_badges_count, dam_badges_count, and so on), origin_url
DAMFrontendAnnouncementprivate-user.{loginUserId}.DAMFrontendAnnouncementNotificationDAMFrontendAnnouncementdata (badge data)
GetUserSubscriptionEventprivate-user.{userId}.getUserSubscriptionChannelGetUserSubscriptionEventplan_assign (true when the workspace's SubscriptionUsers.features is set)
LogoutDealershipUserprivate-logoutDealershipUser.{userId}logoutDealershipUserdata (the event data)
PrivateEventprivate-user.{id}privateEventid, name

GetUserSubscriptionEvent::broadcastWith() has a side effect: it writes event_sent (1 or 0) on the SubscriptionUsers row and saves it.

Clients subscribe with the name after the private- prefix, for example user.42.projectBatchNotification, and listen for the broadcastAs name with a leading dot.

Driver ​

The broadcaster is BROADCAST_DRIVER in config/broadcasting.php, defaulting to null. The config defines pusher, ably, redis, log and null connections. Which one is set in each environment is not visible in the repo.

Channel authorization ​

App\Providers\BroadcastServiceProvider calls Broadcast::routes(['middleware' => ['auth:api,dam-api']]) (dd4df4a), which registers the /broadcasting/auth endpoint behind either the Passport api guard (Admin users) or dam-api (portal users), then loads routes/channels.php. Every channel callback allows the user only when the ID in the channel name equals the authenticated user's ID, and each channel names the one guard allowed to subscribe, because users.id and dealer_users.id overlap.

Channel patternGuardUsed by
App.User.{id}apiLaravel default, no event uses it
user.{id}apiPrivateEvent
user.{user_id}.projectBatchNotificationapiProjectUserNotificationBadgesEvent
user.{user_id}.DAMFrontendAnnouncementNotificationdam-apiDAMFrontendAnnouncement
user.{user_id}.getUserSubscriptionChannelapiGetUserSubscriptionEvent
logoutDealershipUser.{user_id}dam-apiLogoutDealershipUser

The broadcasting auth route is listed with the other web routes in Web routes.

Push notifications ​

App\PushNotification\PushNotification sends mobile push messages to every DeviceToken.fcm_token of a user through the legacy FCM HTTP endpoint (https://fcm.googleapis.com/fcm/send, Authorization: key=...) with cURL. A user who has muted the module in MuteNotifications gets the message with no sound and normal priority; otherwise default sound and high priority. The badge number comes from ProjectUserNotificationBadges.

PushNotificationServiceProvider binds the class to the container key PushNotification, and config/app.php aliases the facade PushNotification to App\PushNotification\PushNotificationFacade. The provider is listed three times in config/app.php; the duplicates are harmless.

MethodServer keyPurposeCalled from
sendNotification(...)FCM_SERVER_KEY envLegacy PM module task pushNo caller found
sendReportNotification(...)FCM_SERVER_KEY envLegacy report pushNo caller found
sendLmNotification(...)FCM_SERVER_KEY envLegacy LM module pushNo caller found
static sendDamNotification(...)constant.DAM_FCM_SERVER_KEYDAM order status push to adminsNo caller found
static sendDamAnnouncementNotification($moduleId, $type, $title, $workspaceId, $userId)constant.DAM_FCM_SERVER_KEYDAM announcement push to portal usersAnnouncementNotification job, alongside the DAMFrontendAnnouncement broadcast

Google shut down the legacy FCM send API in 2024, so these calls may no longer deliver. Moving to the FCM HTTP v1 API would need OAuth service-account credentials instead of a server key. This was not tested from the repo.