diff --git a/app/init.php b/app/init.php index f2d8d63298..0861f67e7a 100644 --- a/app/init.php +++ b/app/init.php @@ -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\Auth\Phone\Msg91; use Appwrite\DSN\DSN; use Appwrite\Event\Audit; use Appwrite\Event\Database as EventDatabase; @@ -990,6 +991,7 @@ App::setResource('phone', function () { 'twilio' => new Twilio($user, $secret), 'text-magic' => new TextMagic($user, $secret), 'telesign' => new Telesign($user, $secret), + 'msg91' => new Msg91($user, $secret), default => null }; }); diff --git a/app/workers/messaging.php b/app/workers/messaging.php index 409304c595..c83eaa2d7b 100644 --- a/app/workers/messaging.php +++ b/app/workers/messaging.php @@ -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\Auth\Phone\Msg91; use Appwrite\DSN\DSN; use Appwrite\Resque\Worker; use Utopia\App; @@ -36,6 +37,7 @@ class MessagingV1 extends Worker 'twilio' => new Twilio($user, $secret), 'text-magic' => new TextMagic($user, $secret), 'telesign' => new Telesign($user, $secret), + 'msg91' => new Msg91($user, $secret), default => null }; diff --git a/src/Appwrite/Auth/Phone/Msg91.php b/src/Appwrite/Auth/Phone/Msg91.php new file mode 100644 index 0000000000..64e5973597 --- /dev/null +++ b/src/Appwrite/Auth/Phone/Msg91.php @@ -0,0 +1,46 @@ + utilized from for flow id + * @param string $to + * @param string $message + * @return void + */ + public function send(string $from, string $to, string $message): void + { + $to = ltrim($to, '+'); + $this->request( + method: 'POST', + url: $this->endpoint, + payload: json_encode([ + 'sender' => $this->user, + 'otp' => $message, + 'flow_id' => $from, + 'mobiles' => $to + ]), + headers: [ + "content-type: application/JSON", + "authkey: {$this->secret}", + ] + ); + } +}