2024-05-22 07:23:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
|
2024-06-10 20:43:34 +00:00
|
|
|
class PullTemplatesFromCDN implements ShouldBeEncrypted, ShouldQueue
|
2024-05-22 07:23:17 +00:00
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
public $timeout = 10;
|
|
|
|
|
2024-06-19 06:59:46 +00:00
|
|
|
public function __construct() {}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-05-22 07:23:17 +00:00
|
|
|
public function handle(): void
|
|
|
|
{
|
|
|
|
try {
|
2024-06-10 20:43:34 +00:00
|
|
|
if (! isDev()) {
|
2024-05-23 09:12:37 +00:00
|
|
|
ray('PullTemplatesAndVersions service-templates');
|
|
|
|
$response = Http::retry(3, 1000)->get(config('constants.services.official'));
|
|
|
|
if ($response->successful()) {
|
|
|
|
$services = $response->json();
|
|
|
|
File::put(base_path('templates/service-templates.json'), json_encode($services));
|
|
|
|
} else {
|
2024-06-10 20:43:34 +00:00
|
|
|
send_internal_notification('PullTemplatesAndVersions failed with: '.$response->status().' '.$response->body());
|
2024-05-23 09:12:37 +00:00
|
|
|
}
|
2024-05-22 07:23:17 +00:00
|
|
|
}
|
|
|
|
} catch (\Throwable $e) {
|
2024-06-10 20:43:34 +00:00
|
|
|
send_internal_notification('PullTemplatesAndVersions failed with: '.$e->getMessage());
|
2024-05-22 07:23:17 +00:00
|
|
|
ray($e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|