From 22eab51c56c9a06e26a892b57e9b9d392e4e1da0 Mon Sep 17 00:00:00 2001 From: larswolff Date: Fri, 6 Dec 2024 19:56:46 +0100 Subject: [PATCH] Bugfix for PR 275 - omit socket-id if null (#280) * Omit the socket_id key from the payload, unless a socket_id exists * Update EventDispatcher.php --------- Co-authored-by: Taylor Otwell --- src/Protocols/Pusher/EventDispatcher.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Protocols/Pusher/EventDispatcher.php b/src/Protocols/Pusher/EventDispatcher.php index fe5830a..c4e8f22 100644 --- a/src/Protocols/Pusher/EventDispatcher.php +++ b/src/Protocols/Pusher/EventDispatcher.php @@ -24,12 +24,17 @@ public static function dispatch(Application $app, array $payload, ?Connection $c return; } - app(PubSubProvider::class)->publish([ + $data = [ 'type' => 'message', 'application' => serialize($app), 'payload' => $payload, - 'socket_id' => $connection?->id(), - ]); + ]; + + if ($connection?->id() !== null) { + $data['socket_id'] = $connection?->id(); + } + + app(PubSubProvider::class)->publish($data); } /**