This commit is contained in:
ct
2025-08-11 02:35:35 +08:00
parent 4a80723243
commit f3c91b9a64
24 changed files with 2035 additions and 214 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Observers;
use App\Models\CrawlShotJob;
use App\Services\WebhookService;
class CrawlShotJobObserver
{
public function updated(CrawlShotJob $crawlShotJob): void
{
// Only fire webhook if status has changed and webhook_url is set
if ($crawlShotJob->isDirty('status') && $crawlShotJob->webhook_url) {
$eventsFilter = $crawlShotJob->webhook_events_filter ?? ['queued', 'processing', 'completed', 'failed'];
// Don't fire webhook if filter is empty array
if (empty($eventsFilter)) {
return;
}
// Only fire webhook if current status is in the filter
if (in_array($crawlShotJob->status, $eventsFilter)) {
WebhookService::send($crawlShotJob);
}
}
}
}