Removed DB connection
This commit is contained in:
parent
3804f718a4
commit
79bf99372e
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue