feat: use DSN for phone provider
This commit is contained in:
parent
3c3261b7f1
commit
400f5c4b48
4
.env
4
.env
|
@ -56,9 +56,7 @@ _APP_SMTP_PORT=1025
|
|||
_APP_SMTP_SECURE=
|
||||
_APP_SMTP_USERNAME=
|
||||
_APP_SMTP_PASSWORD=
|
||||
_APP_PHONE_PROVIDER=mock
|
||||
_APP_PHONE_USER=
|
||||
_APP_PHONE_SECRET=
|
||||
_APP_PHONE_PROVIDER=phone://mock
|
||||
_APP_PHONE_FROM=
|
||||
_APP_STORAGE_LIMIT=30000000
|
||||
_APP_STORAGE_PREVIEW_LIMIT=20000000
|
||||
|
|
1
.github/workflows/tests.yml
vendored
1
.github/workflows/tests.yml
vendored
|
@ -41,6 +41,7 @@ jobs:
|
|||
- name: Teardown
|
||||
if: always()
|
||||
run: |
|
||||
docker compose down -v
|
||||
docker ps -aq | xargs docker rm --force
|
||||
docker volume prune --force
|
||||
docker network prune --force
|
|
@ -402,24 +402,6 @@ return [
|
|||
'question' => '',
|
||||
'filter' => ''
|
||||
],
|
||||
[
|
||||
'name' => '_APP_PHONE_USER',
|
||||
'description' => '',
|
||||
'introduction' => '',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
'question' => '',
|
||||
'filter' => ''
|
||||
],
|
||||
[
|
||||
'name' => '_APP_PHONE_SECRET',
|
||||
'description' => '',
|
||||
'introduction' => '',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
'question' => '',
|
||||
'filter' => ''
|
||||
],
|
||||
[
|
||||
'name' => '_APP_PHONE_FROM',
|
||||
'description' => '',
|
||||
|
|
|
@ -27,6 +27,7 @@ use Appwrite\Auth\Phone\Mock;
|
|||
use Appwrite\Auth\Phone\Telesign;
|
||||
use Appwrite\Auth\Phone\TextMagic;
|
||||
use Appwrite\Auth\Phone\Twilio;
|
||||
use Appwrite\DSN\DSN;
|
||||
use Appwrite\Event\Audit;
|
||||
use Appwrite\Event\Database as EventDatabase;
|
||||
use Appwrite\Event\Delete;
|
||||
|
@ -969,11 +970,11 @@ App::setResource('geodb', function ($register) {
|
|||
}, ['register']);
|
||||
|
||||
App::setResource('phone', function () {
|
||||
$provider = App::getEnv('_APP_PHONE_PROVIDER');
|
||||
$user = App::getEnv('_APP_PHONE_USER');
|
||||
$secret = App::getEnv('_APP_PHONE_SECRET');
|
||||
$dsn = new DSN(App::getEnv('_APP_PHONE_PROVIDER'));
|
||||
$user = $dsn->getUser();
|
||||
$secret = $dsn->getPassword();
|
||||
|
||||
return match ($provider) {
|
||||
return match ($dsn->getHost()) {
|
||||
'mock' => new Mock('', ''), // used for tests
|
||||
'twilio' => new Twilio($user, $secret),
|
||||
'text-magic' => new TextMagic($user, $secret),
|
||||
|
|
|
@ -5,6 +5,7 @@ use Appwrite\Auth\Phone\Mock;
|
|||
use Appwrite\Auth\Phone\Telesign;
|
||||
use Appwrite\Auth\Phone\TextMagic;
|
||||
use Appwrite\Auth\Phone\Twilio;
|
||||
use Appwrite\DSN\DSN;
|
||||
use Appwrite\Resque\Worker;
|
||||
use Utopia\App;
|
||||
use Utopia\CLI\Console;
|
||||
|
@ -26,12 +27,11 @@ class MessagingV1 extends Worker
|
|||
|
||||
public function init(): void
|
||||
{
|
||||
$provider = App::getEnv('_APP_PHONE_PROVIDER');
|
||||
$user = App::getEnv('_APP_PHONE_USER');
|
||||
$secret = App::getEnv('_APP_PHONE_SECRET');
|
||||
$dsn = new DSN(App::getEnv('_APP_PHONE_PROVIDER'));
|
||||
$user = $dsn->getUser();
|
||||
$secret = $dsn->getPassword();
|
||||
|
||||
$this->from = App::getEnv('_APP_PHONE_FROM');
|
||||
$this->phone = match ($provider) {
|
||||
$this->phone = match ($dsn->getHost()) {
|
||||
'mock' => new Mock('', ''), // used for tests
|
||||
'twilio' => new Twilio($user, $secret),
|
||||
'text-magic' => new TextMagic($user, $secret),
|
||||
|
|
Loading…
Reference in a new issue