From 1a81f10d89d047b687332650517511c0822a46c9 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Tue, 30 Nov 2021 16:11:45 +0000 Subject: [PATCH 1/8] Add a DNS warning during install --- app/config/variables.php | 2 +- app/tasks/install.php | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/config/variables.php b/app/config/variables.php index e6313a9776..e57f4fb420 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', diff --git a/app/tasks/install.php b/app/tasks/install.php index 0898ae67c1..24743403ae 100644 --- a/app/tasks/install.php +++ b/app/tasks/install.php @@ -11,6 +11,19 @@ use Utopia\Config\Config; use Utopia\View; use Utopia\Validator\Text; +function formatArray(array $arr) { + $mask = "%10.10s %-10.10s %10.10s\n"; + printf($mask, "Type", "Name", "Value"); + + // array_walk($arr, function(&$key) use ($descriptionColumnLimit){ + // $key = explode("\n", wordwrap($key, $descriptionColumnLimit)); + // }); + + foreach($arr as $key => $value) { + printf($mask, $key, $value[0], $value[1]); + } +} + $cli ->task('install') ->desc('Install Appwrite') @@ -167,6 +180,16 @@ $cli if(empty($input[$var['name']])) { $input[$var['name']] = $var['default']; } + + if ($var['filter'] === 'domainTarget') { + if ($input[$var['name']] !== 'localhost') { + Console::warning("If you haven't already done so, make sure you create an 'A' or 'AAAA' DNS record for '".$input[$var['name']]."' pointing to your external server IP. \nYour DNS Table should look like so: "); + formatArray([ + 'A/AAAA' => ['@', 'Your IP'], + ]); + Console::warning("Use 'AAAA' if you have an IPv6 address and 'A' if you have an IPv4 address."); + } + } } $templateForCompose = new View(__DIR__.'/../views/install/compose.phtml'); From c1ef83eec74058e8837770a1ac3964f8e27449cf Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 1 Dec 2021 02:39:42 +0400 Subject: [PATCH 2/8] feat: update PR --- app/tasks/install.php | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/app/tasks/install.php b/app/tasks/install.php index 24743403ae..9f3f138dd9 100644 --- a/app/tasks/install.php +++ b/app/tasks/install.php @@ -11,19 +11,6 @@ use Utopia\Config\Config; use Utopia\View; use Utopia\Validator\Text; -function formatArray(array $arr) { - $mask = "%10.10s %-10.10s %10.10s\n"; - printf($mask, "Type", "Name", "Value"); - - // array_walk($arr, function(&$key) use ($descriptionColumnLimit){ - // $key = explode("\n", wordwrap($key, $descriptionColumnLimit)); - // }); - - foreach($arr as $key => $value) { - printf($mask, $key, $value[0], $value[1]); - } -} - $cli ->task('install') ->desc('Install Appwrite') @@ -183,11 +170,11 @@ $cli if ($var['filter'] === 'domainTarget') { if ($input[$var['name']] !== 'localhost') { - Console::warning("If you haven't already done so, make sure you create an 'A' or 'AAAA' DNS record for '".$input[$var['name']]."' pointing to your external server IP. \nYour DNS Table should look like so: "); - formatArray([ - 'A/AAAA' => ['@', 'Your IP'], - ]); - Console::warning("Use 'AAAA' if you have an IPv6 address and 'A' if you have an IPv4 address."); + Console::info("\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::info("\nUse 'AAAA' if you're using an IPv6 address and 'A' if you're using an IPv4 address.\n"); } } } From 859444703faeaee9fb2123aef719cb9c989a3c73 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 1 Dec 2021 02:41:53 +0400 Subject: [PATCH 3/8] feat: update PR --- app/tasks/install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/tasks/install.php b/app/tasks/install.php index 9f3f138dd9..6ada31d09e 100644 --- a/app/tasks/install.php +++ b/app/tasks/install.php @@ -170,11 +170,11 @@ $cli if ($var['filter'] === 'domainTarget') { if ($input[$var['name']] !== 'localhost') { - Console::info("\nIf you haven't already done so, set the following record for {$input[$var['name']]} on your DNS provider: \n"); + 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::info("\nUse 'AAAA' if you're using an IPv6 address and 'A' if you're using an IPv4 address.\n"); + Console::warning("\nUse 'AAAA' if you're using an IPv6 address and 'A' if you're using an IPv4 address.\n"); } } } From f70e2479062b4c47da0ceff0e3ddf0a49c1c5803 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 9 May 2022 13:13:41 +0100 Subject: [PATCH 4/8] Update app/tasks/install.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matej Bačo --- app/tasks/install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/tasks/install.php b/app/tasks/install.php index 6ada31d09e..da2ad8d5a6 100644 --- a/app/tasks/install.php +++ b/app/tasks/install.php @@ -173,7 +173,7 @@ $cli 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", "@", ""); + 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"); } } From f63c1c95fe0148ccebeca5755c77d32d669a7c3c Mon Sep 17 00:00:00 2001 From: Aditya Oberai Date: Tue, 12 Jul 2022 15:45:22 +0000 Subject: [PATCH 5/8] Create Vonage phone auth adapter --- app/init.php | 2 ++ app/workers/messaging.php | 2 ++ src/Appwrite/Auth/Phone/Vonage.php | 42 ++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/Appwrite/Auth/Phone/Vonage.php 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/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/src/Appwrite/Auth/Phone/Vonage.php b/src/Appwrite/Auth/Phone/Vonage.php new file mode 100644 index 0000000000..bf95360b22 --- /dev/null +++ b/src/Appwrite/Auth/Phone/Vonage.php @@ -0,0 +1,42 @@ +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 + ]) + ); + } +} From 313fd5582ae4c4fcba6a30f24e9a04d373a53aea Mon Sep 17 00:00:00 2001 From: Aditya Oberai <31401437+adityaoberai@users.noreply.github.com> Date: Tue, 12 Jul 2022 22:03:54 +0530 Subject: [PATCH 6/8] Set $from to use env variable + update ref link --- src/Appwrite/Auth/Phone/Vonage.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Appwrite/Auth/Phone/Vonage.php b/src/Appwrite/Auth/Phone/Vonage.php index bf95360b22..0a2c6dcbaa 100644 --- a/src/Appwrite/Auth/Phone/Vonage.php +++ b/src/Appwrite/Auth/Phone/Vonage.php @@ -5,7 +5,7 @@ namespace Appwrite\Auth\Phone; use Appwrite\Auth\Phone; // Reference Material -// https://dashboard.nexmo.com/getting-started/sms +// https://developer.vonage.com/api/sms class Vonage extends Phone { @@ -23,7 +23,6 @@ class Vonage extends Phone public function send(string $from, string $to, string $message): void { $to = ltrim($to, '+'); - $from = "Appwrite"; $headers = ['Content-Type: application/x-www-form-urlencoded']; $this->request( From d93ac31b4e0a5c6b209526889d0dddf0377b4460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 13 Jul 2022 08:57:57 +0000 Subject: [PATCH 7/8] Fix function usage missing --- app/controllers/api/functions.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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); From 0fbfabe5d31e38fe35bc6accdd98e7c88c18108e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 13 Jul 2022 16:48:39 +0000 Subject: [PATCH 8/8] CLI lib version increase --- composer.json | 4 ++-- composer.lock | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/composer.json b/composer.json index 1cc1385c13..c95dbab819 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "utopia-php/analytics": "0.2.*", "utopia-php/audit": "0.8.*", "utopia-php/cache": "0.6.*", - "utopia-php/cli": "0.12.*", + "utopia-php/cli": "0.13.*", "utopia-php/config": "0.2.*", "utopia-php/database": "0.18.*", "utopia-php/locale": "0.4.*", @@ -59,7 +59,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 e079cf0bc0..379a3727a6 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": "eacaae6ec0973349a9b9f4ec78877b0a", + "content-hash": "380d806f7540199698d12a7abeb13534", "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", @@ -2051,16 +2051,16 @@ }, { "name": "utopia-php/database", - "version": "dev-feat-permissions-maxlength", + "version": "0.18.7", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "85c304075bb42b91e3cb98762921f15fa28af13c" + "reference": "d542ee433f1a545d926ffaf707bdf952dc18a52e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/85c304075bb42b91e3cb98762921f15fa28af13c", - "reference": "85c304075bb42b91e3cb98762921f15fa28af13c", + "url": "https://api.github.com/repos/utopia-php/database/zipball/d542ee433f1a545d926ffaf707bdf952dc18a52e", + "reference": "d542ee433f1a545d926ffaf707bdf952dc18a52e", "shasum": "" }, "require": { @@ -2109,9 +2109,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/feat-permissions-maxlength" + "source": "https://github.com/utopia-php/database/tree/0.18.7" }, - "time": "2022-07-10T17:08:47+00:00" + "time": "2022-07-11T10:20:33+00:00" }, { "name": "utopia-php/domains", @@ -2387,21 +2387,21 @@ }, { "name": "utopia-php/orchestration", - "version": "0.4.1", + "version": "dev-cli-lib-upgrade", "source": { "type": "git", "url": "https://github.com/utopia-php/orchestration.git", - "reference": "67cf0ab15a096d274c093ea918aa4ace14ac7af7" + "reference": "06f2afef516aca900ddb483689ebe6f8e7037d28" }, "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/06f2afef516aca900ddb483689ebe6f8e7037d28", + "reference": "06f2afef516aca900ddb483689ebe6f8e7037d28", "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/cli-lib-upgrade" }, - "time": "2022-02-20T09:23:06+00:00" + "time": "2022-07-13T14:55:12+00:00" }, { "name": "utopia-php/preloader", @@ -5348,15 +5348,15 @@ ], "aliases": [ { - "package": "utopia-php/database", - "version": "dev-feat-permissions-maxlength", - "alias": "0.18.1", - "alias_normalized": "0.18.1.0" + "package": "utopia-php/orchestration", + "version": "dev-cli-lib-upgrade", + "alias": "0.4.1", + "alias_normalized": "0.4.1.0" } ], "minimum-stability": "stable", "stability-flags": { - "utopia-php/database": 20 + "utopia-php/orchestration": 20 }, "prefer-stable": false, "prefer-lowest": false,