Updated functions trigger
This commit is contained in:
parent
af470a3f1a
commit
a8cc398c85
|
@ -321,6 +321,7 @@ App::put('/v1/functions/:functionId')
|
|||
if ($next && $schedule !== $original) {
|
||||
ResqueScheduler::enqueueAt($next, 'v1-functions', 'FunctionsV1', [
|
||||
'projectId' => $project->getId(),
|
||||
'webhooks' => $project->getAttribute('webhooks', []),
|
||||
'functionId' => $function->getId(),
|
||||
'executionId' => null,
|
||||
'trigger' => 'schedule',
|
||||
|
@ -375,6 +376,7 @@ App::patch('/v1/functions/:functionId/tag')
|
|||
if ($next) { // Init first schedule
|
||||
ResqueScheduler::enqueueAt($next, 'v1-functions', 'FunctionsV1', [
|
||||
'projectId' => $project->getId(),
|
||||
'webhooks' => $project->getAttribute('webhooks', []),
|
||||
'functionId' => $function->getId(),
|
||||
'executionId' => null,
|
||||
'trigger' => 'schedule',
|
||||
|
|
|
@ -76,6 +76,7 @@ App::init(function ($utopia, $request, $response, $project, $user, $register, $e
|
|||
*/
|
||||
$events
|
||||
->setParam('projectId', $project->getId())
|
||||
->setParam('webhooks', $project->getAttribute('webhooks', []))
|
||||
->setParam('userId', $user->getId())
|
||||
->setParam('event', $route->getLabel('event', ''))
|
||||
->setParam('eventData', [])
|
||||
|
@ -188,7 +189,6 @@ App::shutdown(function ($utopia, $request, $response, $project, $events, $audits
|
|||
$webhooks
|
||||
->setQueue('v1-webhooks')
|
||||
->setClass('WebhooksV1')
|
||||
->setParam('webhooks', $project->getAttribute('webhooks', []))
|
||||
->trigger();
|
||||
|
||||
$functions
|
||||
|
|
|
@ -141,6 +141,7 @@ class FunctionsV1
|
|||
|
||||
$projectId = $this->args['projectId'] ?? '';
|
||||
$functionId = $this->args['functionId'] ?? '';
|
||||
$webhooks = $this->args['webhooks'] ?? [];
|
||||
$executionId = $this->args['executionId'] ?? '';
|
||||
$trigger = $this->args['trigger'] ?? '';
|
||||
$event = $this->args['event'] ?? '';
|
||||
|
@ -196,7 +197,7 @@ class FunctionsV1
|
|||
|
||||
Console::success('Triggered function: '.$event);
|
||||
|
||||
$this->execute('event', $projectId, '', $database, $function, $event, $eventData, $data, $userId, $jwt);
|
||||
$this->execute('event', $projectId, '', $database, $function, $event, $eventData, $data, $webhooks, $userId, $jwt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -252,7 +253,7 @@ class FunctionsV1
|
|||
'scheduleOriginal' => $function->getAttribute('schedule', ''),
|
||||
]); // Async task rescheduale
|
||||
|
||||
$this->execute($trigger, $projectId, $executionId, $database, $function, /*$event*/'', /*$eventData*/'', $data, $userId, $jwt);
|
||||
$this->execute($trigger, $projectId, $executionId, $database, $function, /*$event*/'', /*$eventData*/'', $data, $webhooks, $userId, $jwt);
|
||||
break;
|
||||
|
||||
case 'http':
|
||||
|
@ -264,7 +265,7 @@ class FunctionsV1
|
|||
throw new Exception('Function not found ('.$functionId.')');
|
||||
}
|
||||
|
||||
$this->execute($trigger, $projectId, $executionId, $database, $function, /*$event*/'', /*$eventData*/'', $data, $userId, $jwt);
|
||||
$this->execute($trigger, $projectId, $executionId, $database, $function, /*$event*/'', /*$eventData*/'', $data, $webhooks, $userId, $jwt);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -287,7 +288,7 @@ class FunctionsV1
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute(string $trigger, string $projectId, string $executionId, Database $database, Document $function, string $event = '', string $eventData = '', string $data = '', string $userId = '', string $jwt = ''): void
|
||||
public function execute(string $trigger, string $projectId, string $executionId, Database $database, Document $function, string $event = '', string $eventData = '', string $data = '', array $webhooks = [], string $userId = '', string $jwt = ''): void
|
||||
{
|
||||
global $list;
|
||||
|
||||
|
@ -479,6 +480,7 @@ class FunctionsV1
|
|||
$executionUpdate
|
||||
->setParam('projectId', $projectId)
|
||||
->setParam('userId', $userId)
|
||||
->setParam('webhooks', $webhooks)
|
||||
->setParam('event', 'functions.executions.update')
|
||||
->setParam('eventData', [
|
||||
'$id' => $execution['$id'],
|
||||
|
|
Loading…
Reference in a new issue