Implement webhook inspector

This commit is contained in:
2026-08-04 17:09:39 +02:00
parent b021836c14
commit 75d8b25b64
57 changed files with 5110 additions and 230 deletions
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\WebhookEndpoint;
class WebhookEndpointPolicy
{
public function viewAny(?User $user): bool
{
return $user !== null;
}
public function view(?User $user, WebhookEndpoint $webhookEndpoint): bool
{
return $webhookEndpoint->is_public || $this->isOwner($user, $webhookEndpoint);
}
public function create(?User $user): bool
{
return $user !== null;
}
public function update(?User $user, WebhookEndpoint $webhookEndpoint): bool
{
return ! $webhookEndpoint->is_public && $this->isOwner($user, $webhookEndpoint);
}
public function delete(?User $user, WebhookEndpoint $webhookEndpoint): bool
{
return ($webhookEndpoint->is_public && $webhookEndpoint->user_id === null)
|| $this->isOwner($user, $webhookEndpoint);
}
private function isOwner(?User $user, WebhookEndpoint $webhookEndpoint): bool
{
return $user !== null && (string) $webhookEndpoint->user_id === (string) $user->getKey();
}
}