diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 0df59e3e5b..3e9caed315 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -369,7 +369,6 @@ App::patch('/v1/functions/:functionId/deployment') $function = $dbForProject->getDocument('functions', $functionId); $deployment = $dbForProject->getDocument('deployments', $deployment); - var_dump($deployment); $build = $dbForProject->getDocument('builds', $deployment->getAttribute('buildId', '')); if ($function->isEmpty()) { @@ -846,7 +845,7 @@ App::post('/v1/functions/:functionId/executions') ]); $response->setStatusCode(Response::STATUS_CODE_CREATED); - $response->dynamic($execution, Response::MODEL_EXECUTION); + return $response->dynamic($execution, Response::MODEL_EXECUTION); } /** Collect environment variables */ diff --git a/app/workers/functions.php b/app/workers/functions.php index f1970b1962..52c3df4fb1 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -334,16 +334,16 @@ class FunctionsV1 extends Worker ->setParam('projectId', $projectId) ->setParam('userId', $userId) ->setParam('webhooks', $webhooks) - ->setParam('event', $event) + ->setParam('event', 'functions.executions.update') ->setParam('eventData', $execution->getArrayCopy(array_keys($executionModel->getRules()))); $executionUpdate->trigger(); /** Trigger realtime event */ - $target = Realtime::fromPayload($event, $execution); + $target = Realtime::fromPayload('functions.executions.update', $execution); Realtime::send( projectId: $projectId, payload: $execution->getArrayCopy(), - event: $event, + event: 'functions.executions.update', channels: $target['channels'], roles: $target['roles'] ); diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index e297c30d7e..fa4ff4d7c4 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -176,7 +176,6 @@ class Executor curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36'); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); diff --git a/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php b/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php index 95b4dd4423..8f8e467ea3 100644 --- a/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php +++ b/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php @@ -1049,6 +1049,15 @@ class RealtimeCustomClientTest extends Scope $this->assertNotEmpty($responseUpdate['data']['payload']); $client->close(); + + // Cleanup : Delete function + $response = $this->client->call(Client::METHOD_DELETE, '/functions/'. $functionId, [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], []); + + $this->assertEquals(204, $response['headers']['status-code']); } public function testChannelTeams(): array