feat(settings): enable_automation gate; reject stale montzar quote jumps
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Models\Automation;
|
||||
use App\Services\Automation\AutomationCatalog;
|
||||
use App\Services\Automation\AutomationEngine;
|
||||
use App\Services\Automation\AutomationFingerprint;
|
||||
use App\Services\ConfigService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
@@ -16,6 +17,7 @@ class AutomationController extends Controller
|
||||
{
|
||||
public function table(Request $request)
|
||||
{
|
||||
$this->assertFeatureEnabled();
|
||||
$query = Automation::query();
|
||||
TableEngine::create($query, $request->all())
|
||||
->initSearch(['name', 'code', 'title', 'body'])
|
||||
@@ -27,11 +29,14 @@ class AutomationController extends Controller
|
||||
|
||||
public function catalog()
|
||||
{
|
||||
$this->assertFeatureEnabled();
|
||||
|
||||
return response()->json(app(AutomationCatalog::class)->toArray());
|
||||
}
|
||||
|
||||
public function preview(Request $request)
|
||||
{
|
||||
$this->assertFeatureEnabled();
|
||||
$conditions = array_values((array) $request->input('conditions', []));
|
||||
$count = app(AutomationEngine::class)->previewCount($conditions);
|
||||
|
||||
@@ -40,6 +45,7 @@ class AutomationController extends Controller
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$this->assertFeatureEnabled();
|
||||
$data = $this->validated($request);
|
||||
$data['created_by'] = auth()->id();
|
||||
$row = Automation::create($data);
|
||||
@@ -49,6 +55,7 @@ class AutomationController extends Controller
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$this->assertFeatureEnabled();
|
||||
$row = Automation::query()->findOrFail($id);
|
||||
$data = $this->validated($request, (int) $row->id);
|
||||
$row->fill($data)->save();
|
||||
@@ -58,6 +65,7 @@ class AutomationController extends Controller
|
||||
|
||||
public function toggle($id)
|
||||
{
|
||||
$this->assertFeatureEnabled();
|
||||
$row = Automation::query()->findOrFail($id);
|
||||
if (! $row->is_active) {
|
||||
$dup = $this->duplicateOf($row->logic_fingerprint, (int) $row->id, true);
|
||||
@@ -75,11 +83,19 @@ class AutomationController extends Controller
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->assertFeatureEnabled();
|
||||
Automation::query()->findOrFail($id)->delete();
|
||||
|
||||
return response()->json(true);
|
||||
}
|
||||
|
||||
private function assertFeatureEnabled(): void
|
||||
{
|
||||
if (! app(ConfigService::class)->isAutomationEnabled()) {
|
||||
throw new UnprocessableEntityHttpException('قابلیت اتوماسیون خاموش است.');
|
||||
}
|
||||
}
|
||||
|
||||
private function validated(Request $request, ?int $ignoreId = null): array
|
||||
{
|
||||
$name = trim((string) $request->input('name', ''));
|
||||
|
||||
Reference in New Issue
Block a user