2026-05-24 12:17:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Actions\Automation\Run;
|
|
|
|
|
|
|
|
|
|
use App\Enums\Automation\Run\Status;
|
|
|
|
|
use App\Jobs\Automation\ProcessAutomationNode;
|
|
|
|
|
use App\Models\AutomationRun;
|
2026-06-13 16:59:52 +00:00
|
|
|
use DomainException;
|
2026-05-24 12:17:19 +00:00
|
|
|
|
|
|
|
|
class RetryRunFromNode
|
|
|
|
|
{
|
|
|
|
|
public function __invoke(AutomationRun $run, string $nodeId): void
|
|
|
|
|
{
|
|
|
|
|
if ($run->status !== Status::Failed) {
|
2026-06-13 16:59:52 +00:00
|
|
|
throw new DomainException(__('automations.errors.only_failed_can_retry'));
|
2026-05-24 12:17:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$run->update([
|
|
|
|
|
'status' => Status::Pending,
|
|
|
|
|
'error' => null,
|
|
|
|
|
'finished_at' => null,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
ProcessAutomationNode::dispatch($run, $nodeId);
|
|
|
|
|
}
|
|
|
|
|
}
|