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(); + }); } /**