From cf1c22a0c9795497c0a875226a65c999261e2b53 Mon Sep 17 00:00:00 2001 From: Steve Moretz Date: Mon, 14 Oct 2024 21:21:17 +0330 Subject: [PATCH] Update EchoBroadcaster.php --- .../Broadcasters/EchoBroadcaster.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Subscriptions/Broadcasters/EchoBroadcaster.php b/src/Subscriptions/Broadcasters/EchoBroadcaster.php index 8f0d1aee5e..57fcc4fd50 100644 --- a/src/Subscriptions/Broadcasters/EchoBroadcaster.php +++ b/src/Subscriptions/Broadcasters/EchoBroadcaster.php @@ -8,6 +8,7 @@ use Nuwave\Lighthouse\Subscriptions\Contracts\Broadcaster; use Nuwave\Lighthouse\Subscriptions\Events\EchoSubscriptionEvent; use Nuwave\Lighthouse\Subscriptions\Subscriber; +use Illuminate\Support\Facades\Broadcast; class EchoBroadcaster implements Broadcaster { @@ -24,17 +25,15 @@ public function broadcast(Subscriber $subscriber, mixed $data): void public function authorized(Request $request): JsonResponse { - $userId = md5( - $request->input('channel_name') - . $request->input('socket_id'), + $pusher = Broadcast::getPusher(); + $channel = $request->input('channel_name'); + $socketId = $request->input('socket_id'); + $data = \Safe\json_decode( + $pusher->socket_auth($channel, $socketId), + true, ); - return new JsonResponse([ - 'channel_data' => [ - 'user_id' => $userId, - 'user_info' => [], - ], - ], 200); + return new JsonResponse($data, 200); } public function unauthorized(Request $request): JsonResponse