Update
This commit is contained in:
40
app/Jobs/RetryWebhookJob.php
Normal file
40
app/Jobs/RetryWebhookJob.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user