From 61dcb9a3bac68b4a8f8837047ec6939127faf66e Mon Sep 17 00:00:00 2001 From: JoanFo <161775222+JoanFo1456@users.noreply.github.com> Date: Wed, 10 Sep 2025 16:39:50 +0200 Subject: [PATCH] Fixed Allocations not calling webhooks on server creation & Object events (#1595) --- app/Jobs/ProcessWebhook.php | 4 +++- app/Services/Servers/ServerCreationService.php | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/Jobs/ProcessWebhook.php b/app/Jobs/ProcessWebhook.php index 5105266a2..ff414ab72 100644 --- a/app/Jobs/ProcessWebhook.php +++ b/app/Jobs/ProcessWebhook.php @@ -12,6 +12,7 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Http; use App\Enums\WebhookType; +use Illuminate\Support\Arr; class ProcessWebhook implements ShouldQueue { @@ -32,7 +33,8 @@ class ProcessWebhook implements ShouldQueue if (count($data) === 1) { $data = reset($data); } - $data = is_array($data) ? $data : (json_decode($data, true) ?? []); + + $data = Arr::wrap(json_decode($data, true) ?? []); $data['event'] = $this->webhookConfiguration->transformClassName($this->eventName); if ($this->webhookConfiguration->type === WebhookType::Discord) { diff --git a/app/Services/Servers/ServerCreationService.php b/app/Services/Servers/ServerCreationService.php index 9d1c6cd94..fa744911c 100644 --- a/app/Services/Servers/ServerCreationService.php +++ b/app/Services/Servers/ServerCreationService.php @@ -184,9 +184,15 @@ class ServerCreationService $records = array_merge($records, $data['allocation_additional']); } - Allocation::query()->whereIn('id', $records)->update([ - 'server_id' => $server->id, - ]); + Allocation::query() + ->whereIn('id', array_values(array_unique($records))) + ->whereNull('server_id') + ->lockForUpdate() + ->get() + ->each(function (Allocation $allocation) use ($server) { + $allocation->server_id = $server->id; + $allocation->save(); + }); } /**