From 9c9551da7925b584d710a4abfc1b6c0238a39a0a Mon Sep 17 00:00:00 2001 From: Sylvester Damgaard Date: Thu, 16 May 2024 13:40:48 +0200 Subject: [PATCH] Ignore locks on API requests --- src/Listeners/LockListener.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Listeners/LockListener.php b/src/Listeners/LockListener.php index 2baa1b1..71b8005 100755 --- a/src/Listeners/LockListener.php +++ b/src/Listeners/LockListener.php @@ -7,6 +7,7 @@ use Statamic\Events; use Statamic\Facades\Site; use Statamic\Facades\User; +use Statamic\Support\Str; use Tv2regionerne\StatamicLocks\Models\LockModel; class LockListener @@ -16,6 +17,14 @@ public function handle($event) $itemId = false; $itemType = false; + $path = request()->path(); + + // ignore locks on API requests + if (Str::of($path)->startsWith('api')) { + return; + } + + if ($event instanceof Events\AssetSaving) { $itemId = $event->asset->id() ?? false; $itemType = 'asset';