1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

Removed DB connection

This commit is contained in:
Eldad Fux 2021-05-17 12:49:17 +03:00
parent 3804f718a4
commit 79bf99372e
2 changed files with 3 additions and 25 deletions

View file

@ -188,6 +188,7 @@ App::shutdown(function ($utopia, $request, $response, $project, $events, $audits
$webhooks
->setQueue('v1-webhooks')
->setClass('WebhooksV1')
->setParam('webhooks', $project->getAttribute('webhooks', []))
->trigger();
$functions

View file

@ -2,11 +2,6 @@
use Utopia\App;
use Utopia\CLI\Console;
use Utopia\Config\Config;
use Appwrite\Database\Database;
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
use Appwrite\Database\Adapter\Redis as RedisAdapter;
use Appwrite\Database\Validator\Authorization;
require_once __DIR__.'/../init.php';
@ -24,34 +19,16 @@ class WebhooksV1
public function perform()
{
global $register;
$consoleDB = new Database();
$consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register));
$consoleDB->setNamespace('app_console'); // Main DB
$consoleDB->setMocks(Config::getParam('collections', []));
$errors = [];
// Event
$projectId = $this->args['projectId'] ?? '';
$webhooks = $this->args['webhooks'] ?? [];
$userId = $this->args['userId'] ?? '';
$event = $this->args['event'] ?? '';
$eventData = \json_encode($this->args['eventData']);
// Webhook
Authorization::disable();
$project = $consoleDB->getDocument($projectId);
Authorization::reset();
if (\is_null($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS !== $project->getCollection()) {
throw new Exception('Project Not Found');
}
foreach ($project->getAttribute('webhooks', []) as $webhook) {
foreach ($webhooks as $webhook) {
if (!(isset($webhook['events']) && \is_array($webhook['events']) && \in_array($event, $webhook['events']))) {
continue;
}