diff --git a/app/config/variables.php b/app/config/variables.php index 5f3cd430e9..7b4c4b4ace 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -68,7 +68,7 @@ return [ 'default' => 'localhost', 'required' => true, 'question' => 'Enter a DNS A record hostname to serve as a CNAME for your custom domains.' . PHP_EOL . 'You can use the same value as used for the Appwrite hostname.', - 'filter' => '' + 'filter' => 'domainTarget' ], [ 'name' => '_APP_CONSOLE_WHITELIST_ROOT', @@ -647,7 +647,7 @@ return [ ], [ 'name' => '_APP_FUNCTIONS_TIMEOUT', - 'description' => 'The maximum number of seconds allowed as a timeout value when creating a new function. The default value is 900 seconds.', + 'description' => 'The maximum number of seconds allowed as a timeout value when creating a new function. The default value is 900 seconds. This is the global limit, timeout for individual functions are configured in the function\'s settings or in appwrite.json.', 'introduction' => '0.7.0', 'default' => '900', 'required' => false, diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 0137ab92a8..21b827042d 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -806,7 +806,8 @@ App::post('/v1/functions/:functionId/executions') ->inject('dbForProject') ->inject('user') ->inject('events') - ->action(function (string $functionId, string $data, bool $async, Response $response, Document $project, Database $dbForProject, Document $user, Event $events) { + ->inject('usage') + ->action(function (string $functionId, string $data, bool $async, Response $response, Document $project, Database $dbForProject, Document $user, Event $events, Stats $usage) { $function = Authorization::skip(fn () => $dbForProject->getDocument('functions', $functionId)); @@ -958,6 +959,12 @@ App::post('/v1/functions/:functionId/executions') Authorization::skip(fn () => $dbForProject->updateDocument('executions', $executionId, $execution)); + $usage + ->setParam('functionId', $function->getId()) + ->setParam('functionExecution', 1) + ->setParam('functionStatus', $execution->getAttribute('status', '')) + ->setParam('functionExecutionTime', $execution->getAttribute('time') * 1000); // ms + $response ->setStatusCode(Response::STATUS_CODE_CREATED) ->dynamic($execution, Response::MODEL_EXECUTION); diff --git a/app/init.php b/app/init.php index 0861f67e7a..71407699b8 100644 --- a/app/init.php +++ b/app/init.php @@ -28,6 +28,7 @@ use Appwrite\Auth\Phone\Telesign; use Appwrite\Auth\Phone\TextMagic; use Appwrite\Auth\Phone\Twilio; use Appwrite\Auth\Phone\Msg91; +use Appwrite\Auth\Phone\Vonage; use Appwrite\DSN\DSN; use Appwrite\Event\Audit; use Appwrite\Event\Database as EventDatabase; @@ -992,6 +993,7 @@ App::setResource('phone', function () { 'text-magic' => new TextMagic($user, $secret), 'telesign' => new Telesign($user, $secret), 'msg91' => new Msg91($user, $secret), + 'vonage' => new Vonage($user, $secret), default => null }; }); diff --git a/app/tasks/install.php b/app/tasks/install.php index 6349a162fa..3519b58d0b 100644 --- a/app/tasks/install.php +++ b/app/tasks/install.php @@ -173,6 +173,16 @@ $cli if (empty($input[$var['name']])) { $input[$var['name']] = $var['default']; } + + if ($var['filter'] === 'domainTarget') { + if ($input[$var['name']] !== 'localhost') { + Console::warning("\nIf you haven't already done so, set the following record for {$input[$var['name']]} on your DNS provider:\n"); + $mask = "%-15.15s %-10.10s %-30.30s\n"; + printf($mask, "Type", "Name", "Value"); + printf($mask, "A or AAAA", "@", ""); + Console::warning("\nUse 'AAAA' if you're using an IPv6 address and 'A' if you're using an IPv4 address.\n"); + } + } } $templateForCompose = new View(__DIR__ . '/../views/install/compose.phtml'); diff --git a/app/workers/messaging.php b/app/workers/messaging.php index c83eaa2d7b..fd6eed6c22 100644 --- a/app/workers/messaging.php +++ b/app/workers/messaging.php @@ -6,6 +6,7 @@ use Appwrite\Auth\Phone\Telesign; use Appwrite\Auth\Phone\TextMagic; use Appwrite\Auth\Phone\Twilio; use Appwrite\Auth\Phone\Msg91; +use Appwrite\Auth\Phone\Vonage; use Appwrite\DSN\DSN; use Appwrite\Resque\Worker; use Utopia\App; @@ -38,6 +39,7 @@ class MessagingV1 extends Worker 'text-magic' => new TextMagic($user, $secret), 'telesign' => new Telesign($user, $secret), 'msg91' => new Msg91($user, $secret), + 'vonage' => new Vonage($user, $secret), default => null }; diff --git a/composer.json b/composer.json index d29a6d4e8f..77d0cb5500 100644 --- a/composer.json +++ b/composer.json @@ -48,8 +48,8 @@ "utopia-php/analytics": "0.2.*", "utopia-php/audit": "0.8.*", "utopia-php/cache": "0.6.*", - "utopia-php/cli": "0.12.0", "utopia-php/platform": "dev-dev", + "utopia-php/cli": "0.13.*", "utopia-php/config": "0.2.*", "utopia-php/database": "0.18.*", "utopia-php/locale": "0.4.*", @@ -60,7 +60,7 @@ "utopia-php/storage": "0.9.*", "utopia-php/websocket": "0.1.0", "utopia-php/image": "0.5.*", - "utopia-php/orchestration": "0.4.*", + "utopia-php/orchestration": "0.6.*", "resque/php-resque": "1.3.6", "matomo/device-detector": "6.0.0", "dragonmantank/cron-expression": "3.3.1", diff --git a/composer.lock b/composer.lock index bf8963e887..7f26a6e167 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": "3775608dcbc4262c4edd8710aa94ce4d", + "content-hash": "0568e4057b8c49ea008ce2e3a1c83e94", "packages": [ { "name": "adhocore/jwt", @@ -1947,16 +1947,16 @@ }, { "name": "utopia-php/cli", - "version": "0.12.0", + "version": "0.13.0", "source": { "type": "git", "url": "https://github.com/utopia-php/cli.git", - "reference": "6d164b752efeb1ca089e3a517bc274d8b383474b" + "reference": "69e68f8ed525fe162fae950a0507ed28a0f179bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cli/zipball/6d164b752efeb1ca089e3a517bc274d8b383474b", - "reference": "6d164b752efeb1ca089e3a517bc274d8b383474b", + "url": "https://api.github.com/repos/utopia-php/cli/zipball/69e68f8ed525fe162fae950a0507ed28a0f179bc", + "reference": "69e68f8ed525fe162fae950a0507ed28a0f179bc", "shasum": "" }, "require": { @@ -1994,9 +1994,9 @@ ], "support": { "issues": "https://github.com/utopia-php/cli/issues", - "source": "https://github.com/utopia-php/cli/tree/0.12.0" + "source": "https://github.com/utopia-php/cli/tree/0.13.0" }, - "time": "2022-02-18T22:10:41+00:00" + "time": "2022-04-26T08:41:22+00:00" }, { "name": "utopia-php/config", @@ -2387,21 +2387,21 @@ }, { "name": "utopia-php/orchestration", - "version": "0.4.1", + "version": "0.6.0", "source": { "type": "git", "url": "https://github.com/utopia-php/orchestration.git", - "reference": "67cf0ab15a096d274c093ea918aa4ace14ac7af7" + "reference": "94263976413871efb6b16157a7101a81df3b6d78" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/orchestration/zipball/67cf0ab15a096d274c093ea918aa4ace14ac7af7", - "reference": "67cf0ab15a096d274c093ea918aa4ace14ac7af7", + "url": "https://api.github.com/repos/utopia-php/orchestration/zipball/94263976413871efb6b16157a7101a81df3b6d78", + "reference": "94263976413871efb6b16157a7101a81df3b6d78", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/cli": "0.12.*" + "utopia-php/cli": "0.13.*" }, "require-dev": { "phpunit/phpunit": "^9.3", @@ -2436,9 +2436,9 @@ ], "support": { "issues": "https://github.com/utopia-php/orchestration/issues", - "source": "https://github.com/utopia-php/orchestration/tree/0.4.1" + "source": "https://github.com/utopia-php/orchestration/tree/0.6.0" }, - "time": "2022-02-20T09:23:06+00:00" + "time": "2022-07-13T16:47:18+00:00" }, { "name": "utopia-php/platform", @@ -2446,13 +2446,13 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "4327c4cbaafc39cd94ec4d977cbdc25c8e9df613" + "reference": "fd133dd0f4d464c3aa6b4e5c338f7fc7201f8e4d" }, "require": { "ext-json": "*", "ext-redis": "*", "php": ">=8.0", - "utopia-php/cli": "0.12.*", + "utopia-php/cli": "0.13.*", "utopia-php/framework": "dev-feat-public-add-route as 0.19.21" }, "require-dev": { @@ -2474,6 +2474,9 @@ "format": [ "vendor/bin/phpcbf" ], + "lint": [ + "vendor/bin/phpcs" + ], "test": [ "docker-compose up -d && sleep 10 && docker-compose exec web vendor/bin/phpunit --configuration phpunit.xml" ] @@ -2495,7 +2498,7 @@ "upf", "utopia" ], - "time": "2022-07-14T07:30:15+00:00" + "time": "2022-07-17T01:05:38+00:00" }, { "name": "utopia-php/preloader", diff --git a/src/Appwrite/Auth/Phone/Vonage.php b/src/Appwrite/Auth/Phone/Vonage.php new file mode 100644 index 0000000000..0a2c6dcbaa --- /dev/null +++ b/src/Appwrite/Auth/Phone/Vonage.php @@ -0,0 +1,41 @@ +request( + method: 'POST', + url: $this->endpoint, + headers: $headers, + payload: \http_build_query([ + 'text' => $message, + 'from' => $from, + 'to' => $to, + 'api_key' => $this->user, + 'api_secret' => $this->secret + ]) + ); + } +}