diff --git a/app/config/events.php b/app/config/events.php index 47b902fb82..8cda7d5be2 100644 --- a/app/config/events.php +++ b/app/config/events.php @@ -132,6 +132,11 @@ return [ 'model' => Response::MODEL_EXECUTION, 'note' => 'version >= 0.7', ], + 'functions.executions.update' => [ + 'description' => 'This event triggers when a function execution is updated.', + 'model' => Response::MODEL_EXECUTION, + 'note' => 'version >= 0.7', + ], 'storage.files.create' => [ 'description' => 'This event triggers when a storage file is created.', 'model' => Response::MODEL_FILE, diff --git a/app/workers/functions.php b/app/workers/functions.php index 87e3a86245..f24b556104 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -469,6 +469,28 @@ class FunctionsV1 throw new Exception('Failed saving execution to DB', 500); } + var_dump($execution); + $executionUpdate = new Event('v1-webhooks', 'WebhooksV1'); + + $executionUpdate + ->setParam('projectId', $projectId) + ->setParam('userId', '') + ->setParam('event', 'functions.executions.update') + ->setParam('payload', [ + '$id' => $execution['$id'], + 'functionId' => $execution['functionId'], + 'dateCreated' => $execution['dateCreated'], + 'trigger' => $execution['trigger'], + 'status' => $execution['status'], + 'exitCode' => $execution['exitCode'], + 'stdout' => $execution['stdout'], + 'stderr' => $execution['stderr'], + 'time' => $execution['time'] + ]); + + $executionUpdate->trigger(); + + $usage = new Event('v1-usage', 'UsageV1'); $usage