* Manual automations * Scheduled automations * Incoming webhook triggers * Domain-event trigger foundation * Ordered automation steps * Queued execution * Run status and execution history * Per-step execution logs * Continue-or-stop-on-failure control * Email actions * Outgoing webhook actions * Application log actions * Delay actions * Secure incoming webhook secrets * Automation trigger and action registries * Extensible action and trigger contracts * Scheduled automation Artisan command * Administration navigation * Automation permissions * Module registration and boot test
17 lines
863 B
PHP
17 lines
863 B
PHP
<?php
|
|
namespace Modules\Automation\Http\Controllers;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Modules\Automation\Models\Automation;
|
|
use Modules\Automation\Services\AutomationRunner;
|
|
final class AutomationApiController extends Controller
|
|
{
|
|
public function trigger(Request $request,Automation $automation,AutomationRunner $runner): JsonResponse
|
|
{
|
|
abort_unless($automation->trigger_type==='webhook',404); $secret=(string)($automation->trigger_config['secret']??'');
|
|
if($secret!=='') abort_unless(hash_equals($secret,(string)$request->header('X-Automation-Secret')),401,'Invalid automation secret.');
|
|
$run=$runner->dispatch($automation,$request->all(),'webhook'); return response()->json(['data'=>['execution_id'=>$run->execution_id,'status'=>$run->status]],202);
|
|
}
|
|
}
|