41 lines
1017 B
PHP
41 lines
1017 B
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\CrawlShotJob;
|
|
use App\Services\WebhookService;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class RetryWebhookJob implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
protected string $jobUuid;
|
|
|
|
public function __construct(string $jobUuid)
|
|
{
|
|
$this->jobUuid = $jobUuid;
|
|
}
|
|
|
|
public function handle(): void
|
|
{
|
|
$job = CrawlShotJob::where('uuid', $this->jobUuid)->first();
|
|
|
|
if (!$job || !$job->webhook_url) {
|
|
return;
|
|
}
|
|
|
|
// Check if job still needs retry (in case it was manually cleared)
|
|
if (!$job->webhook_next_retry_at || $job->webhook_next_retry_at->isFuture()) {
|
|
return;
|
|
}
|
|
|
|
// Attempt webhook again
|
|
WebhookService::send($job);
|
|
}
|
|
}
|