Add SMS checks

This commit is contained in:
David Bomba 2024-03-17 15:25:31 +11:00
parent 8a54df3cf6
commit 80b944f822
7 changed files with 88474 additions and 3 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Http\Requests\CompanyGateway;
use App\Http\Requests\Request;
use App\Utils\Traits\MakesHash;
use Illuminate\Validation\Rule;
class TestCompanyGatewayRequest extends Request
{
use MakesHash;
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize(): bool
{
/** @var \App\Models\User $user */
$user = auth()->user();
return $user->isAdmin();
}
public function rules()
{
return [
];
}
public function prepareForValidation()
{
$input = $this->all();
$this->replace($input);
}
}

View File

@ -5,7 +5,7 @@
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
*1`
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -224,7 +224,7 @@ class NinjaMailerJob implements ShouldQueue
private function incrementEmailCounter(): void
{
if(in_array($this->mailer, ['default','mailgun']))
if(in_array($this->mailer, ['default','mailgun','postmark']))
Cache::increment("email_quota".$this->company->account->key);
}

View File

@ -21,6 +21,7 @@ use Illuminate\Support\Str;
use App\Models\CompanyToken;
use App\Models\ClientContact;
use App\Models\VendorContact;
use App\DataProviders\SMSNumbers;
use Illuminate\Support\Facades\DB;
/**
@ -537,6 +538,10 @@ class MultiDB
$current_db = config('database.default');
if(SMSNumbers::numberExists($phone)){
return true;
}
foreach (self::$dbs as $db) {
self::setDB($db);
if ($exists = Account::where('account_sms_verification_number', $phone)->where('account_sms_verified', true)->exists()) {

View File

@ -246,7 +246,7 @@ class Email implements ShouldQueue
private function incrementEmailCounter(): void
{
if(in_array($this->mailer, ['default','mailgun']))
if(in_array($this->mailer, ['default','mailgun','postmark']))
Cache::increment("email_quota".$this->company->account->key);
}

View File

@ -0,0 +1,36 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Unit;
use App\DataProviders\SMSNumbers;
use Tests\TestCase;
/**
* @test
*/
class SmsNumberTest extends TestCase
{
public function testArrayHit()
{
$this->assertTrue(SMSNumbers::hasNumber("+461614222"));
}
public function testArrayMiss()
{
$this->assertFalse(SMSNumbers::hasNumber("+5485454"));
}
public function testSmsArrayType()
{
$this->assertIsArray(SMSNumbers::getNumbers());
}
}