diff --git a/routes/channels.php b/routes/channels.php index 265099e..79e19cd 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -15,7 +15,17 @@ use Illuminate\Support\Facades\DB; | */ +Broadcast::channel('chat.support', function ($user) { + return ChatSupport::isOperator($user); +}); + Broadcast::channel('chat.{conversationId}', function ($user, $conversationId) { + if (! ctype_digit((string) $conversationId)) { + return false; + } + + $conversationId = (int) $conversationId; + $isParticipant = DB::table('conversation_user') ->where('conversation_id', $conversationId) ->where('user_id', $user->id) @@ -26,9 +36,5 @@ Broadcast::channel('chat.{conversationId}', function ($user, $conversationId) { } return ChatSupport::isOperator($user) - && ChatSupport::conversationIncludesSupport((int) $conversationId); -}); - -Broadcast::channel('chat.support', function ($user) { - return ChatSupport::isOperator($user); + && ChatSupport::conversationIncludesSupport($conversationId); });