Fixed Allocations not calling webhooks on server creation & Object events (#1595)

This commit is contained in:
JoanFo 2025-09-10 16:39:50 +02:00 committed by GitHub
parent 0e34886d7e
commit 61dcb9a3ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View File

@ -12,6 +12,7 @@ use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Enums\WebhookType; use App\Enums\WebhookType;
use Illuminate\Support\Arr;
class ProcessWebhook implements ShouldQueue class ProcessWebhook implements ShouldQueue
{ {
@ -32,7 +33,8 @@ class ProcessWebhook implements ShouldQueue
if (count($data) === 1) { if (count($data) === 1) {
$data = reset($data); $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); $data['event'] = $this->webhookConfiguration->transformClassName($this->eventName);
if ($this->webhookConfiguration->type === WebhookType::Discord) { if ($this->webhookConfiguration->type === WebhookType::Discord) {

View File

@ -184,9 +184,15 @@ class ServerCreationService
$records = array_merge($records, $data['allocation_additional']); $records = array_merge($records, $data['allocation_additional']);
} }
Allocation::query()->whereIn('id', $records)->update([ Allocation::query()
'server_id' => $server->id, ->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();
});
} }
/** /**