diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 620f0cbe2a..e69ba94537 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -1025,10 +1025,10 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId') ->param('security', false, new Boolean(true), 'Certificate verification, false for disabled or true for enabled.') ->param('httpUser', '', new Text(256), 'Webhook HTTP user. Max length: 256 chars.', true) ->param('httpPass', '', new Text(256), 'Webhook HTTP password. Max length: 256 chars.', true) - ->param('enable', false, new Boolean(), 'Enable a disabled webhook.', true) + ->param('enabled', false, new Boolean(), 'Enable a disabled webhook.', true) ->inject('response') ->inject('dbForConsole') - ->action(function (string $projectId, string $webhookId, string $name, array $events, string $url, bool $security, string $httpUser, string $httpPass, bool $enable, Response $response, Database $dbForConsole) { + ->action(function (string $projectId, string $webhookId, string $name, array $events, string $url, bool $security, string $httpUser, string $httpPass, bool $enabled, Response $response, Database $dbForConsole) { $project = $dbForConsole->getDocument('projects', $projectId); diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index 2dc28c1227..5bf4ba8706 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -12,7 +12,7 @@ use Utopia\Queue\Message; class Webhooks extends Action { private array $errors = []; - private const FAILEDATTEMPTSCOUNT = 10; + private const MAX_FAILED_ATTEMPTS = 10; public static function getName(): string { @@ -123,19 +123,19 @@ class Webhooks extends Action if (false === \curl_exec($ch)) { $dbForConsole->increaseDocumentAttribute('webhooks', $webhook->getId(), 'attempts', 1); $webhook = $dbForConsole->getDocument('webhooks', $webhook->getId()); - $errorCount = $webhook->getAttribute('attempts'); - $lastErrorLogs = \curl_error($ch) . ' in events ' . implode(', ', $events); - $webhook->setAttribute('logs', $lastErrorLogs); + $attempts = $webhook->getAttribute('attempts'); + $logs = \curl_error($ch) . ' in events ' . implode(', ', $events); + $webhook->setAttribute('logs', $logs); // $statusCode = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); - if ($errorCount >= self::FAILEDATTEMPTSCOUNT) { + if ($attempts >= self::MAX_FAILED_ATTEMPTS) { $webhook->setAttribute('enabled', false); } $dbForConsole->updateDocument('webhooks', $webhook->getId(), $webhook); $dbForConsole->deleteCachedDocument('projects', $project->getId()); - $this->errors[] = $lastErrorLogs; + $this->errors[] = $logs; } \curl_close($ch);