diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index e2a3c2de6b..1aa4b3bf92 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -41,6 +41,7 @@ use Utopia\Validator\HexColor; use Utopia\Validator\Range; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; +use Utopia\DSN\DSN; use Utopia\Swoole\Request; App::post('/v1/storage/buckets') diff --git a/app/init.php b/app/init.php index 8768103e84..5846a7ba8a 100644 --- a/app/init.php +++ b/app/init.php @@ -54,7 +54,6 @@ use Utopia\Config\Config; use Utopia\Locale\Locale; use Utopia\Registry\Registry; use Utopia\Storage\Device; -use Utopia\Storage\Storage; use Utopia\DSN\DSN; use Utopia\Storage\Device\Backblaze; use Utopia\Storage\Device\DOSpaces; @@ -75,6 +74,7 @@ use Appwrite\Event\Func; use MaxMind\Db\Reader; use PHPMailer\PHPMailer\PHPMailer; use Swoole\Database\PDOProxy; +use Utopia\CLI\Console; use Utopia\Queue; const APP_NAME = 'Appwrite'; @@ -593,7 +593,7 @@ $register->set('pools', function () { $dsnUser = $dsn->getUser(); $dsnPass = $dsn->getPassword(); $dsnScheme = $dsn->getScheme(); - $dsnDatabase = $dsn->getDatabase(); + $dsnDatabase = $dsn->getPath(); if (!in_array($dsnScheme, $schemes)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, "Invalid console database scheme"); @@ -653,7 +653,7 @@ $register->set('pools', function () { default => null }; - $adapter->setDefaultDatabase($dsn->getDatabase()); + $adapter->setDefaultDatabase($dsn->getPath()); break; case 'pubsub': $adapter = $resource(); @@ -1035,6 +1035,7 @@ App::setResource('console', function () { 'legalAddress' => '', 'legalTaxId' => '', 'auths' => [ + 'invites' => false, 'limit' => (App::getEnv('_APP_CONSOLE_WHITELIST_ROOT', 'enabled') === 'enabled') ? 1 : 0, // limit signup to 1 user ], 'authWhitelistEmails' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null)) : [], @@ -1123,7 +1124,7 @@ function getDevice($root): Device $bucket = $dsn->getPath(); $region = $dsn->getParam('region'); } catch (\Exception $e) { - Console::eor($e->getMessage() . 'Invalid DSN. Defaulting to Local storage.'); + Console::error($e->getMessage() . 'Invalid DSN. Defaulting to Local storage.'); $device = STORAGE_DEVICE_LOCAL; } diff --git a/app/workers/builds.php b/app/workers/builds.php index 348794c743..6535a56b05 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -11,7 +11,7 @@ use Utopia\Database\DateTime; use Utopia\App; use Utopia\CLI\Console; use Utopia\Database\ID; -use Utopia\Storage\Storage; +use Utopia\DSN\DSN; use Utopia\Database\Document; use Utopia\Config\Config; use Utopia\Database\Validator\Authorization; diff --git a/app/workers/messaging.php b/app/workers/messaging.php index 8d13919f2e..4c82a1abff 100644 --- a/app/workers/messaging.php +++ b/app/workers/messaging.php @@ -6,7 +6,7 @@ use Appwrite\SMS\Adapter\TextMagic; use Appwrite\SMS\Adapter\Twilio; use Appwrite\SMS\Adapter\Msg91; use Appwrite\SMS\Adapter\Vonage; -use Appwrite\DSN\DSN; +use Utopia\DSN\DSN; use Appwrite\Resque\Worker; use Appwrite\SMS\Adapter; use Utopia\App; diff --git a/composer.json b/composer.json index ffd9c6b6b9..2e6098c4c3 100644 --- a/composer.json +++ b/composer.json @@ -54,6 +54,7 @@ "utopia-php/framework": "0.25.*", "utopia-php/image": "0.5.*", "utopia-php/queue": "0.4.*", + "utopia-php/dsn": "0.1.*", "utopia-php/locale": "0.4.*", "utopia-php/logger": "0.3.*", "utopia-php/orchestration": "0.9.*", diff --git a/composer.lock b/composer.lock index 1862ac982c..54caaa313d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a673091aa6bd8ef01380b63245427c93", + "content-hash": "9c2365876e32662c9c62e3a4c738fafe", "packages": [ { "name": "adhocore/jwt", @@ -1943,6 +1943,53 @@ }, "time": "2020-02-23T07:40:02+00:00" }, + { + "name": "utopia-php/dsn", + "version": "0.1.0", + "source": { + "type": "git", + "url": "https://github.com/utopia-php/dsn.git", + "reference": "17a5935eab1b89fb4b95600db50a1b6d5faa6cea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utopia-php/dsn/zipball/17a5935eab1b89fb4b95600db50a1b6d5faa6cea", + "reference": "17a5935eab1b89fb4b95600db50a1b6d5faa6cea", + "shasum": "" + }, + "require": { + "php": ">=8.0" + }, + "require-dev": { + "laravel/pint": "1.2.*", + "phpunit/phpunit": "^9.3", + "squizlabs/php_codesniffer": "^3.6", + "vimeo/psalm": "4.0.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Utopia\\DSN\\": "src/DSN" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A simple library for parsing and managing Data Source Names ( DSNs )", + "keywords": [ + "dsn", + "framework", + "php", + "upf", + "utopia" + ], + "support": { + "issues": "https://github.com/utopia-php/dsn/issues", + "source": "https://github.com/utopia-php/dsn/tree/0.1.0" + }, + "time": "2022-10-26T10:06:20+00:00" + }, { "name": "utopia-php/framework", "version": "0.25.0", diff --git a/src/Appwrite/Resque/Worker.php b/src/Appwrite/Resque/Worker.php index 8503e18c3c..5bf3e254e5 100644 --- a/src/Appwrite/Resque/Worker.php +++ b/src/Appwrite/Resque/Worker.php @@ -7,9 +7,9 @@ use Utopia\App; use Utopia\Cache\Cache; use Utopia\Config\Config; use Utopia\Cache\Adapter\Sharding; +use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Storage\Device; -use Utopia\Storage\Storage; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\DOSpaces; use Utopia\Storage\Device\Linode;