18 lines
549 B
PHP
18 lines
549 B
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use App\Models\WebhookEndpoint;
|
|
use Illuminate\Support\Facades\Broadcast;
|
|
|
|
Broadcast::channel('App.Models.User.{id}', function (User $user, string $id): bool {
|
|
return (string) $user->getKey() === $id;
|
|
});
|
|
|
|
Broadcast::channel('webhooks.{endpointId}', function (User $user, string $endpointId): bool {
|
|
$endpoint = WebhookEndpoint::query()->find($endpointId);
|
|
|
|
return $endpoint instanceof WebhookEndpoint
|
|
&& ! $endpoint->is_public
|
|
&& (string) $endpoint->user_id === (string) $user->getKey();
|
|
});
|