onQueue(isCloud() ? maintenance_queue() : 'default'); } /** * Queues the check and marks it as queued (`RefreshCandidates::isQueued()`). */ public static function queueCheck(ImageScan $scan): void { RefreshCandidates::markQueued($scan, (new self($scan))->uniqueFor); self::dispatch($scan); } public function uniqueId(): string { return (string) $this->scan->id; } public function handle(): void { $scan = $this->scan->fresh(); // The deploy gate or the daily rescan checked it meanwhile. if (! $scan instanceof ImageScan || RefreshCandidates::isFresh($scan)) { RefreshCandidates::forgetQueued($this->scan); return; } try { RefreshCandidates::run($scan, 0, retryWhenBusy: $this->attempts() < $this->tries); RefreshCandidates::forgetQueued($scan); } catch (ScanLockBusy) { $this->release(ScanResourceImagesJob::lockRetryDelay($this->attempts())); } } /** * The check stored no result, so an alert that waits for it is sent now (spec 15.8). */ public function failed(?Throwable $exception): void { RefreshCandidates::forgetQueued($this->scan); $scan = $this->scan->fresh(); if (! $scan instanceof ImageScan) { return; } ScanNotifications::reevaluate($scan, checkGaveUp: true); $resource = $scan->resource; if ($resource instanceof Model) { $teamId = method_exists($resource, 'team') ? $resource->team()?->id : null; ImageScanUpdated::dispatch($teamId, (string) $resource->getAttribute('uuid'), (string) $scan->uuid); } } }