Fixed Allocations not calling webhooks on server creation & Object events (#1595)
This commit is contained in:
parent
0e34886d7e
commit
61dcb9a3ba
@ -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) {
|
||||||
|
@ -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();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user