From 3b70ae4d9fe5fa8f9c561dff2fb80c4862a0fdab Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 22 Apr 2024 07:56:36 +0200 Subject: [PATCH] Fixed formatting --- app/cli.php | 3 +- app/controllers/api/graphql.php | 4 +- app/controllers/api/health.php | 2 +- app/controllers/api/projects.php | 2 +- app/controllers/general.php | 8 +- app/controllers/shared/api.php | 2 +- app/http.php | 2 +- app/init.php | 2 +- app/init/constants.php | 2 +- app/init/database/filters.php | 2 +- app/init/database/formats.php | 2 +- app/init/locale.php | 2 +- app/init2.php | 94 ++++++++------------ app/worker.php | 21 ++--- src/Appwrite/Platform/Tasks/Hamster.php | 1 - src/Appwrite/Platform/Tasks/ScheduleBase.php | 1 - src/Appwrite/Platform/Tasks/Specs.php | 12 +-- src/Appwrite/Platform/Tasks/Version.php | 1 - src/Appwrite/Platform/Workers/Hamster.php | 5 +- src/Appwrite/Platform/Workers/Messaging.php | 1 - src/Appwrite/Platform/Workers/Webhooks.php | 1 - src/Appwrite/Utopia/Response.php | 2 +- tests/unit/Event/EventTest.php | 2 +- tests/unit/Migration/MigrationTest.php | 2 +- tests/unit/Usage/StatsTest.php | 1 - 25 files changed, 74 insertions(+), 103 deletions(-) diff --git a/app/cli.php b/app/cli.php index 55713406e2..9194edd5e1 100644 --- a/app/cli.php +++ b/app/cli.php @@ -17,7 +17,6 @@ use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; -use Utopia\Http\Http; use Utopia\Logger\Log; use Utopia\Platform\Service; use Utopia\Pools\Group; @@ -180,7 +179,7 @@ CLI::setResource('logError', function (Registry $register) { $log->setAction($action); $isProduction = System::getEnv('_APP_ENV', 'development') === 'production'; - + $log->setEnvironment($isProduction ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING); $responseCode = $logger->addLog($log); diff --git a/app/controllers/api/graphql.php b/app/controllers/api/graphql.php index 19958ae309..7104ba5da2 100644 --- a/app/controllers/api/graphql.php +++ b/app/controllers/api/graphql.php @@ -16,10 +16,10 @@ use GraphQL\Validator\Rules\QueryDepth; use Swoole\Coroutine\WaitGroup; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; -use Utopia\System\System; +use Utopia\Http\Http; use Utopia\Http\Validator\JSON; use Utopia\Http\Validator\Text; -use Utopia\Http\Http; +use Utopia\System\System; Http::init() ->groups(['graphql']) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 391b286cca..1c61313ec3 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -89,7 +89,7 @@ Http::get('/v1/health/db') $pool = $pools['pools-'.$key.'-'.$database]['pool']; $dsn = $pools['pools-'.$key.'-'.$database]['dsn']; - + $connection = $pool->get(); $connections->add($connection, $pool); $adapter = match ($dsn->getScheme()) { diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index c1889a5696..6e4415117e 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -198,7 +198,7 @@ Http::post('/v1/projects') $dbForProject->setAuthorization($authorization); $dbForProject->setNamespace("_{$project->getInternalId()}"); $dbForProject->create(); - + $audit = new Audit($dbForProject, $authorization); $audit->setup(); $adapter = new TimeLimit('', 0, 1, $dbForProject, $authorization); diff --git a/app/controllers/general.php b/app/controllers/general.php index 974940cf18..b4fade7b0b 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -23,7 +23,6 @@ use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; -use Utopia\DI\Dependency; use Utopia\Domains\Domain; use Utopia\Http\Http; use Utopia\Http\Route; @@ -33,7 +32,6 @@ use Utopia\Locale\Locale; use Utopia\Logger\Log; use Utopia\Logger\Log\User; use Utopia\Logger\Logger; -use Utopia\Registry\Registry; use Utopia\System\System; Config::setParam('domainVerification', false); @@ -383,7 +381,8 @@ Http::init() Document $console, Document $project, Database $dbForConsole, - Locale $locale, array $localeCodes, + Locale $locale, + array $localeCodes, array $clients, /** * @disregard P1009 Undefined type @@ -392,7 +391,8 @@ Http::init() // Usage $queueForUsage, // Event $queueForEvents, Certificate $queueForCertificates, - Authorization $authorization) { + Authorization $authorization + ) { /* * Appwrite Router */ diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 39926b7182..66dc93f029 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -27,10 +27,10 @@ use Utopia\Database\Document; use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization\Input; -use Utopia\System\System; use Utopia\Http\Http; use Utopia\Http\Route; use Utopia\Http\Validator\WhiteList; +use Utopia\System\System; $parseLabel = function (string $label, array $responsePayload, array $requestParams, Document $user) { preg_match_all('/{(.*?)}/', $label, $matches); diff --git a/app/http.php b/app/http.php index 7bb5ba06be..ec65d7275f 100644 --- a/app/http.php +++ b/app/http.php @@ -245,4 +245,4 @@ Http::init() $authorization->addRole(Role::any()->toString()); }); -$http->start(); \ No newline at end of file +$http->start(); diff --git a/app/init.php b/app/init.php index f10faf5b70..eca05713f0 100644 --- a/app/init.php +++ b/app/init.php @@ -824,7 +824,7 @@ $register->set('pools', function () { //throw new Exception(Exception::GENERAL_SERVER_ERROR, "Missing value for DSN connection in {$key}"); continue; } - + $dsn = new DSN($dsn); $dsnHost = $dsn->getHost(); $dsnPort = $dsn->getPort(); diff --git a/app/init/constants.php b/app/init/constants.php index 615e299776..39eb4a7ad2 100644 --- a/app/init/constants.php +++ b/app/init/constants.php @@ -156,4 +156,4 @@ const METRIC_FUNCTION_ID_EXECUTIONS = '{functionInternalId}.executions'; const METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE = '{functionInternalId}.executions.compute'; const METRIC_NETWORK_REQUESTS = 'network.requests'; const METRIC_NETWORK_INBOUND = 'network.inbound'; -const METRIC_NETWORK_OUTBOUND = 'network.outbound'; \ No newline at end of file +const METRIC_NETWORK_OUTBOUND = 'network.outbound'; diff --git a/app/init/database/filters.php b/app/init/database/filters.php index 84f5adf534..1564d25294 100644 --- a/app/init/database/filters.php +++ b/app/init/database/filters.php @@ -395,4 +395,4 @@ Database::addFilter( function (mixed $value) { return $value; } -); \ No newline at end of file +); diff --git a/app/init/database/formats.php b/app/init/database/formats.php index f1bf54a456..88e46655ac 100644 --- a/app/init/database/formats.php +++ b/app/init/database/formats.php @@ -40,4 +40,4 @@ Structure::addFormat(APP_DATABASE_ATTRIBUTE_FLOAT_RANGE, function ($attribute) { $min = $attribute['formatOptions']['min'] ?? -INF; $max = $attribute['formatOptions']['max'] ?? INF; return new Range($min, $max, Range::TYPE_FLOAT); -}, Database::VAR_FLOAT); \ No newline at end of file +}, Database::VAR_FLOAT); diff --git a/app/init/locale.php b/app/init/locale.php index 7f0c267b0e..122dc89692 100644 --- a/app/init/locale.php +++ b/app/init/locale.php @@ -20,4 +20,4 @@ foreach ($locales as $locale) { } Locale::setLanguageFromJSON($code, $path); -} \ No newline at end of file +} diff --git a/app/init2.php b/app/init2.php index 7970441c32..6e123e796d 100644 --- a/app/init2.php +++ b/app/init2.php @@ -29,37 +29,27 @@ use Appwrite\Event\Messaging; use Appwrite\Event\Migration; use Appwrite\Event\Usage; use Appwrite\Extend\Exception; -use Appwrite\GraphQL\Promises\Adapter\Swoole; -use Appwrite\GraphQL\Schema; use Appwrite\Hooks\Hooks; -use Appwrite\Network\Validator\Email; use Appwrite\Network\Validator\Origin; -use Appwrite\OpenSSL\OpenSSL; use Appwrite\URL\URL; use Appwrite\Utopia\Queue\Connections; use MaxMind\Db\Reader; -use PHPMailer\PHPMailer\PHPMailer; -use Swoole\Coroutine; use Swoole\Database\PDOConfig; use Swoole\Database\PDOPool; use Swoole\Database\PDOProxy; use Swoole\Database\RedisConfig; use Swoole\Database\RedisPool; -use Utopia\Cache\Adapter\Redis as RedisCache; -use Utopia\Cache\Adapter\Sharding; +use Utopia\Cache\Adapter\None; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Adapter\MariaDB; use Utopia\Database\Adapter\MySQL; -use Utopia\Database\Adapter\SQL; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; -use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; -use Utopia\Database\Validator\Datetime as DatetimeValidator; -use Utopia\Database\Validator\Structure; +use Utopia\DI\Container; use Utopia\DI\Dependency; use Utopia\Domains\Validator\PublicDomain; use Utopia\DSN\DSN; @@ -67,14 +57,9 @@ use Utopia\Http\Http; use Utopia\Http\Request; use Utopia\Http\Response; use Utopia\Http\Validator\Hostname; -use Utopia\Http\Validator\IP; -use Utopia\Http\Validator\Range; -use Utopia\Http\Validator\WhiteList; use Utopia\Locale\Locale; use Utopia\Logger\Log; use Utopia\Logger\Logger; -use Utopia\Pools\Group; -use Utopia\Pools\Pool; use Utopia\Queue; use Utopia\Queue\Connection; use Utopia\Registry\Registry; @@ -87,9 +72,6 @@ use Utopia\Storage\Device\S3; use Utopia\Storage\Device\Wasabi; use Utopia\Storage\Storage; use Utopia\System\System; -use Utopia\VCS\Adapter\Git\GitHub as VcsGitHub; -use Utopia\Cache\Adapter\None; -use Utopia\DI\Container; Http::setMode(System::getEnv('_APP_ENV', Http::MODE_TYPE_PRODUCTION)); @@ -210,7 +192,7 @@ $global->set('geodb', function () { }); $global->set('hooks', function () { - return new Hooks(); + return new Hooks(); }); $global->set('pools', (function () { @@ -279,11 +261,11 @@ $global->set('pools', (function () { $name = ($multipe) ? $dsn[0] : 'main'; $config[] = $name; $dsn = $dsn[1] ?? ''; - + if (empty($dsn)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, "Missing value for DSN connection in {$key}"); } - + $dsn = new DSN($dsn); $dsnHost = $dsn->getHost(); $dsnPort = $dsn->getPort(); @@ -306,7 +288,8 @@ $global->set('pools', (function () { switch ($dsnScheme) { case 'mysql': case 'mariadb': - $pool = new PDOPool((new PDOConfig) + $pool = new PDOPool( + (new PDOConfig()) ->withHost($dsnHost) ->withPort($dsnPort) ->withDbName($dsnDatabase) @@ -327,17 +310,16 @@ $global->set('pools', (function () { ); break; case 'redis': - $pool = new RedisPool((new RedisConfig) + $pool = new RedisPool((new RedisConfig()) ->withHost($dsnHost) ->withPort((int)$dsnPort) - ->withAuth($dsnPass) - , $poolSize); + ->withAuth($dsnPass), $poolSize); break; default: throw new Exception(Exception::GENERAL_SERVER_ERROR, "Invalid scheme"); } - + $pools['pools-' . $key . '-' . $name] = [ 'pool' => $pool, 'dsn' => $dsn, @@ -381,32 +363,32 @@ $user $authorization->setDefaultStatus(true); Auth::setCookieName('a_session_' . $project->getId()); - + if (APP_MODE_ADMIN === $mode) { Auth::setCookieName('a_session_' . $console->getId()); } - + $session = Auth::decodeSession( $request->getCookie( Auth::$cookieName, // Get sessions $request->getCookie(Auth::$cookieName . '_legacy', '') ) ); - + // Get session from header for SSR clients if (empty($session['id']) && empty($session['secret'])) { $sessionHeader = $request->getHeader('x-appwrite-session', ''); - + if (!empty($sessionHeader)) { $session = Auth::decodeSession($sessionHeader); } } - + // Get fallback session from old clients (no SameSite support) or clients who block 3rd-party cookies if ($response) { $response->addHeader('X-Debug-Fallback', 'false'); } - + if (empty($session['id']) && empty($session['secret'])) { if ($response) { $response->addHeader('X-Debug-Fallback', 'true'); @@ -415,10 +397,10 @@ $user $fallback = \json_decode($fallback, true); $session = Auth::decodeSession(((isset($fallback[Auth::$cookieName])) ? $fallback[Auth::$cookieName] : '')); } - + Auth::$unique = $session['id'] ?? ''; Auth::$secret = $session['secret'] ?? ''; - + if (APP_MODE_ADMIN !== $mode) { if ($project->isEmpty()) { $user = new Document([]); @@ -432,14 +414,14 @@ $user } else { $user = $dbForConsole->getDocument('users', Auth::$unique); } - + if ( $user->isEmpty() // Check a document has been found in the DB || !Auth::sessionVerify($user->getAttribute('sessions', []), Auth::$secret) ) { // Validate user has valid login token $user = new Document([]); } - + if (APP_MODE_ADMIN === $mode) { if ($user->find('teamId', $project->getAttribute('teamId'), 'memberships')) { $authorization->setDefaultStatus(false); // Cancel security segmentation for admin users. @@ -447,34 +429,34 @@ $user $user = new Document([]); } } - + $authJWT = $request->getHeader('x-appwrite-jwt', ''); - + if (!empty($authJWT) && !$project->isEmpty()) { // JWT authentication $jwt = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway. - + try { $payload = $jwt->decode($authJWT); } catch (JWTException $error) { throw new Exception(Exception::USER_JWT_INVALID, 'Failed to verify JWT. ' . $error->getMessage()); } - + $jwtUserId = $payload['userId'] ?? ''; $jwtSessionId = $payload['sessionId'] ?? ''; - + if ($jwtUserId && $jwtSessionId) { $user = $dbForProject->getDocument('users', $jwtUserId); } - + if (empty($user->find('$id', $jwtSessionId, 'sessions'))) { // Match JWT to active token $user = new Document([]); } } - + // Adds logs to database queries $dbForProject->setMetadata('user', $user->getId()); $dbForConsole->setMetadata('user', $user->getId()); - + return $user; }); $container->set($user); @@ -589,14 +571,14 @@ $dbForProject ->inject('dbForConsole') ->inject('connections') ->inject('authorization') - ->setCallback(function(array $pools, Document $project, Cache $cache, Database $dbForConsole, Connections $connections, Authorization $authorization) { + ->setCallback(function (array $pools, Document $project, Cache $cache, Database $dbForConsole, Connections $connections, Authorization $authorization) { if ($project->isEmpty() || $project->getId() === 'console') { return $dbForConsole; } $pool = $pools['pools-database-'.$project->getAttribute('database')]['pool']; $dsn = $pools['pools-database-'.$project->getAttribute('database')]['dsn']; - + $connection = $pool->get(); $connections->add($connection, $pool); $adapter = match ($dsn->getScheme()) { @@ -606,16 +588,16 @@ $dbForProject }; $adapter->setDatabase($dsn->getPath()); - + $database = new Database($adapter, $cache); $database->setAuthorization($authorization); - + $database ->setNamespace('_' . $project->getInternalId()) ->setMetadata('host', \gethostname()) ->setMetadata('project', $project->getId()) ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS); - + return $database; }); $container->set($dbForProject); @@ -627,7 +609,7 @@ $dbForConsole ->inject('cache') ->inject('authorization') ->inject('connections') - ->setCallback(function(array $pools, Cache $cache, Authorization $authorization, Connections $connections): Database { + ->setCallback(function (array $pools, Cache $cache, Authorization $authorization, Connections $connections): Database { $pool = $pools['pools-console-main']['pool']; $dsn = $pools['pools-console-main']['dsn']; $connection = $pool->get(); @@ -886,7 +868,7 @@ $clients 'type' => Origin::CLIENT_TYPE_WEB, 'hostname' => $request->getHostname(), ], Document::SET_TYPE_APPEND); - + $hostnames = explode(',', System::getEnv('_APP_CONSOLE_HOSTNAMES', '')); $validator = new Hostname(); foreach ($hostnames as $hostname) { @@ -901,7 +883,7 @@ $clients 'hostname' => $hostname, ], Document::SET_TYPE_APPEND); } - + /** * Get All verified client URLs for both console and current projects * + Filter for duplicated entries @@ -913,7 +895,7 @@ $clients fn ($node) => (isset($node['type']) && ($node['type'] === Origin::CLIENT_TYPE_WEB) && isset($node['hostname']) && !empty($node['hostname'])) ) ); - + $clients = \array_unique( \array_merge( $clientsConsole, @@ -926,7 +908,7 @@ $clients ) ) ); - + return $clients; }); $container->set($clients); diff --git a/app/worker.php b/app/worker.php index 9917164c20..66538a939d 100644 --- a/app/worker.php +++ b/app/worker.php @@ -20,10 +20,8 @@ use Appwrite\Platform\Appwrite; use Appwrite\Utopia\Queue\Connections; use Swoole\Runtime; use Utopia\Cache\Adapter\None; -use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\Console; -use Utopia\Config\Config; use Utopia\Database\Adapter\MariaDB; use Utopia\Database\Adapter\MySQL; use Utopia\Database\Database; @@ -38,7 +36,6 @@ use Utopia\Pools\Group; use Utopia\Queue\Connection; use Utopia\Queue\Connection\Redis; use Utopia\Queue\Message; -use Utopia\Queue\Server; use Utopia\Queue\Worker; use Utopia\Registry\Registry; use Utopia\Storage\Device\Local; @@ -114,10 +111,10 @@ $dbForProject if ($project->isEmpty() || $project->getId() === 'console') { return $dbForConsole; } - + $pool = $pools['pools-database-'.$project->getAttribute('database')]['pool']; $dsn = $pools['pools-database-'.$project->getAttribute('database')]['dsn']; - + $connection = $pool->get(); $connections->add($connection, $pool); $adapter = match ($dsn->getScheme()) { @@ -125,9 +122,9 @@ $dbForProject 'mysql' => new MySQL($connection), default => null }; - + $adapter->setDatabase($dsn->getPath()); - + $database = new Database($adapter, $cache); $database->setAuthorization($auth); $database->setNamespace('_' . $project->getInternalId()); @@ -143,11 +140,11 @@ $project ->setCallback(function (Message $message, Database $dbForConsole) { $payload = $message->getPayload() ?? []; $project = new Document($payload['project'] ?? []); - + if ($project->getId() === 'console') { return $project; } - + return $dbForConsole->getDocument('projects', $project->getId()); }); $container->set($project); @@ -170,7 +167,7 @@ $getProjectDB $pool = $pools['pools-database-'.$databaseName]['pool']; $dsn = $pools['pools-database-'.$databaseName]['dsn']; - + $connection = $pool->get(); $connections->add($connection, $pool); $adapter = match ($dsn->getScheme()) { @@ -268,7 +265,7 @@ $queue $dsn = $pools['pools-queue-main']['dsn']; $connection = $pool->get(); $connections->add($connection, $pool); - + return new Redis($dsn->getHost(), $dsn->getPort()); }); $container->set($queue); @@ -558,4 +555,4 @@ Worker::error() $platform ->getWorker() ->setContainer($container) - ->start(); \ No newline at end of file + ->start(); diff --git a/src/Appwrite/Platform/Tasks/Hamster.php b/src/Appwrite/Platform/Tasks/Hamster.php index 1c5cf73c5a..2cfef1a2c9 100644 --- a/src/Appwrite/Platform/Tasks/Hamster.php +++ b/src/Appwrite/Platform/Tasks/Hamster.php @@ -7,7 +7,6 @@ use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; -use Utopia\Http\Http; use Utopia\Platform\Action; use Utopia\System\System; diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index 009f61e3db..a50fbb2403 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -9,7 +9,6 @@ use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception; use Utopia\Database\Query; -use Utopia\Http\Http; use Utopia\Platform\Action; use Utopia\Pools\Group; use Utopia\System\System; diff --git a/src/Appwrite/Platform/Tasks/Specs.php b/src/Appwrite/Platform/Tasks/Specs.php index a24f10960e..44d2b9904c 100644 --- a/src/Appwrite/Platform/Tasks/Specs.php +++ b/src/Appwrite/Platform/Tasks/Specs.php @@ -9,8 +9,6 @@ use Appwrite\Utopia\Response; use Exception; use Swoole\Http\Request as SwooleHttpRequest; use Swoole\Http\Response as SwooleHttpResponse; -use Utopia\Http\Adapter\Swoole\Request; -use Utopia\Http\Adapter\Swoole\Response as HttpResponse; use Utopia\Cache\Adapter\None; use Utopia\Cache\Cache; use Utopia\CLI\Console; @@ -18,12 +16,14 @@ use Utopia\Config\Config; use Utopia\Database\Adapter\MySQL; use Utopia\Database\Database; use Utopia\Http\Adapter\FPM\Server; +use Utopia\Http\Adapter\Swoole\Request; +use Utopia\Http\Adapter\Swoole\Response as HttpResponse; use Utopia\Http\Http; +use Utopia\Http\Validator\Text; +use Utopia\Http\Validator\WhiteList; use Utopia\Platform\Action; use Utopia\Registry\Registry; use Utopia\System\System; -use Utopia\Http\Validator\Text; -use Utopia\Http\Validator\WhiteList; class Specs extends Action { @@ -45,11 +45,11 @@ class Specs extends Action public function action(string $version, string $mode, Registry $register): void { $appRoutes = Http::getRoutes(); - $response = new Response(new HttpResponse(new SwooleHttpResponse)); + $response = new Response(new HttpResponse(new SwooleHttpResponse())); $mocks = ($mode === 'mocks'); // Mock dependencies - Http::setResource('request', fn () => new Request(new SwooleHttpRequest)); + Http::setResource('request', fn () => new Request(new SwooleHttpRequest())); Http::setResource('response', fn () => $response); Http::setResource('dbForConsole', fn () => new Database(new MySQL(''), new Cache(new None()))); Http::setResource('dbForProject', fn () => new Database(new MySQL(''), new Cache(new None()))); diff --git a/src/Appwrite/Platform/Tasks/Version.php b/src/Appwrite/Platform/Tasks/Version.php index c0febe3a31..25e2d13c65 100644 --- a/src/Appwrite/Platform/Tasks/Version.php +++ b/src/Appwrite/Platform/Tasks/Version.php @@ -3,7 +3,6 @@ namespace Appwrite\Platform\Tasks; use Utopia\CLI\Console; -use Utopia\Http\Http; use Utopia\Platform\Action; use Utopia\System\System; diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index 6ae28b25cd..70bfc6e298 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -14,7 +14,6 @@ use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; -use Utopia\Http\Http; use Utopia\Platform\Action; use Utopia\Pools\Group; use Utopia\Queue\Message; @@ -72,11 +71,11 @@ class Hamster extends Action public function action(Message $message, Group $pools, Cache $cache, Database $dbForConsole, Authorization $auth, Connections $connections): void { $token = System::getEnv('_APP_MIXPANEL_TOKEN', ''); - + if (empty($token)) { throw new \Exception('Missing MixPanel Token'); } - + $this->mixpanel = new Mixpanel($token); $payload = $message->getPayload() ?? []; diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index c5e83ee091..c29853d43d 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -12,7 +12,6 @@ use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; use Utopia\DSN\DSN; -use Utopia\Http\Http; use Utopia\Logger\Log; use Utopia\Messaging\Adapter\Email as EmailAdapter; use Utopia\Messaging\Adapter\Email\Mailgun; diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index caab96c4f5..d60946f709 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -8,7 +8,6 @@ use Exception; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; -use Utopia\Http\Http; use Utopia\Logger\Log; use Utopia\Platform\Action; use Utopia\Queue\Message; diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 9c7543dc4e..0f23874fc7 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -458,7 +458,7 @@ class Response extends HttpResponse // Tests (keep last) ->setModel(new Mock()); - parent::__construct($response->swoole); + parent::__construct($response->swoole); } /** diff --git a/tests/unit/Event/EventTest.php b/tests/unit/Event/EventTest.php index 0bdc00da62..1990fddd8d 100644 --- a/tests/unit/Event/EventTest.php +++ b/tests/unit/Event/EventTest.php @@ -11,7 +11,7 @@ use Utopia\Queue; use Utopia\Queue\Client; use Utopia\System\System; -require_once __DIR__ . '/../../../app/init.php'; +//require_once __DIR__ . '/../../../app/init.php'; class EventTest extends TestCase { diff --git a/tests/unit/Migration/MigrationTest.php b/tests/unit/Migration/MigrationTest.php index 536278d55b..8043ec9f94 100644 --- a/tests/unit/Migration/MigrationTest.php +++ b/tests/unit/Migration/MigrationTest.php @@ -36,7 +36,7 @@ abstract class MigrationTest extends TestCase */ public function testMigrationVersions(): void { - require_once __DIR__ . '/../../../app/init.php'; + //require_once __DIR__ . '/../../../app/init.php'; foreach (Migration::$versions as $class) { $this->assertTrue(class_exists('Appwrite\\Migration\\Version\\' . $class)); diff --git a/tests/unit/Usage/StatsTest.php b/tests/unit/Usage/StatsTest.php index 743321397f..534d5beda0 100644 --- a/tests/unit/Usage/StatsTest.php +++ b/tests/unit/Usage/StatsTest.php @@ -5,7 +5,6 @@ namespace Tests\Unit\Usage; use Appwrite\URL\URL as AppwriteURL; use PHPUnit\Framework\TestCase; use Utopia\DSN\DSN; -use Utopia\Http\Http; use Utopia\Queue; use Utopia\Queue\Client; use Utopia\Queue\Connection;